python关于文件操作的一点疑问

2025-04-07 00:50:55
推荐回答(3个)
回答1:

fo=open('renren.txt','a')

官方文档:

mode can be 'r' when the file will only be read, 'w' for only writing (an
existing file with the same name will be erased), and 'a' opens the file for
appending; any data written to the file is automatically added to the end. 'r+' opens the file for
both reading and writing. The mode argument is optional; 'r' will be assumed if it’s
omitted.

回答2:

你好:
那就用追加啊?
四二个参数改为“a”;

回答3:

r+是允许读写,a才是添加