简明 Python 教程 中的例子,python 运行出错,用open代替file()。可以运行。
poem='''/
Programming is fun
When the work is done
if you wanna make your work also fun:
use Python!
'''
f=open('E://test.txt','w')
f.write(poem)
f.close()
f=open('E://test.txt','r')
while True:
line=f.readline()
if len(line) == 0:
break;
print (line)
f.close()
本文通过一个具体的Python代码示例展示了如何使用Python进行文件的读写操作。包括使用open函数打开文件、写入文本以及逐行读取并打印内容。
2713

被折叠的 条评论
为什么被折叠?



