''' Data class'''
import os.path
from random import Random
class TestData(object, Random):
def FetchDataFromFile(self, filename):
""" Open the file as read only """
myfile = open(os.path.join(os.getcwd(),filename), 'r')
""" read the information in the file """
lines = myfile.read()
''' Remove the header as this will not be used '''
header = lines[0]
lines.remove(header)
return lines
ImportError: No module named path
File "pyclasspath/Lib/Testdata.py", line 2, in
os.path中工作的所有其他類在我的項目。有人能指出我在做什麼錯誤嗎?
我把這個文件從一個目錄移到另一個目錄。除此之外,這門課與其他課程沒有區別。
你可以'從os導入路徑',但我認爲首選的方法是'import os',然後在腳本中使用'os.path.method_name()'。如果他使用'從OS進口path' – squiguy 2013-05-13 05:31:19
@squiguy,他需要用'path'上獲得10K代表,而不是'os.path' – 2013-05-13 06:02:27