这是我的主要文件代码
import moduleA as moduleA
import os
filename1 = os.path.join(os.getcwd(),'script01.txt')
filename2 = os.path.join(os.getcwd(),'script02.txt')
myList1 = moduleA.get_file(filename1)
myList2 = moduleA.get_file(filename2)
这是我的moduleA代码
def get_file(filename):
myList = []
with open (filename) as filename:
for line in filename:
myList.append(line)
return myList
我收到一条错误,说get_file中的open(filename)为filename:
TypeError: expected str, bytes or os.PathLike object, not list
我检查过type(filename1)
是字符串。我不知道哪里出错了