onlinezu's recent timeline updates
onlinezu

onlinezu

V2EX member #105687, joined on 2015-03-19 17:25:47 +08:00
在海边搬沙子
onlinezu's recent replies
May 5, 2015
Replied to a topic by onlinezu Python Python 读写文件时如何实现换行?
不知道哪里出错了,请大家指出,到最后没有输出全部,只能得到 a

result1 = [1,"2", "a"]
for item in result1:
print(item)
with open(r'E:\tools\fenci1.txt', 'a+') as file:
file.write("\r\n")
file.write(str(item) + "\r\n")
file.write("".join(str(item)) + os.linesep)
May 3, 2015
Replied to a topic by onlinezu Python Python 读写文件时如何实现换行?
我的是windows,为什么我搜到 http://stackoverflow.com/questions/21636213/why-you-shouldnt-use-os-linesep-when-editing-on-text-mode ,如果写成 f.write(str(word) + \r\n),提示SyntaxError: unexpected character after line continuation character 弄了一个晚上了
@Livid 感觉v2ex上的水帖越来越多了
在知乎上搜到类似问题 http://www.zhihu.com/question/21726578
[email protected] 明年毕业了,努力学习,找好工作
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2259 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 17ms · UTC 16:12 · PVG 00:12 · LAX 09:12 · JFK 12:12
♥ Do have faith in what you're doing.