我具有此功能。
def write_file(tmpdir, filename):
full_file_name = tmpdir/filename
with openFile(filename) as p:
lines = p.readlines()
return lines
我已经通过了我的文件名。例如file.txt,可以编写所有内容。如何在该write_file函数中打印出file.txt文件的所有行?
打印文件行的通用语法
with open(your_file, 'r') as f:
print(''.join([for x in f.readlines()]))