超神奇葩天才 发表于 2021-2-24 22:59:45

open()

fi = open("关山月.txt","r")
fo = open("关山月-诗歌.txt","w")
g = fi.read().split("。")
for a in g:
fo.write(a+"\n")
fo.seek(0)
b = fo.read()#这里有问题
print(b)
fi.close()
fo.close()


怎么改?

jackz007 发表于 2021-2-24 23:34:41

fi = open("关山月.txt","r")
fo = open("关山月-诗歌.txt","w")
fo . write(fi . read())
fi . close()
fo . close()
fi = open("关山月-诗歌.txt")
print(fi . read())
fi . close()

hrp 发表于 2021-2-24 23:42:24

w模式打开文件不可读,试试w+
页: [1]
查看完整版本: open()