如何解决文件处理输出问题,我得到两次输出相同的输出

时间:2019-09-30 03:08:34

标签: python file-handling

我正在使用python中的文件。我正在尝试从当前已写入的文件中读取。在读取文件时,输出被打印两次。

myfile = open('example_file.txt','w')

myfile.write('why is this getting printed twice')

myfile.close()


myfile = open('example_file.txt')

print(myfile.read())

myfile.close()

我希望输出为 为什么要打印两次

但实际输出是 为什么要打印两次 为什么要打印两次

0 个答案:

没有答案