2024-05-03 13:07:56 发布
网友
出于某种原因,它是假的。我使用了比较运算符。该文件工作正常。比较似乎有问题
您可以按如下方式打开文件并加载其内容:
def open_file(): with open("filename", "r") as f: lines = f.readlines()
用all_lines = open_file()调用函数
all_lines = open_file()
然后逐行阅读:
for line in all_lines: Print(line)
with open(filename, 'r') as fh: for line in fh: ... do stuff with line ...
您可以按如下方式打开文件并加载其内容:
用
all_lines = open_file()
调用函数然后逐行阅读:
相关问题 更多 >
编程相关推荐