''' 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