→ drjoey:雖然我也常常 print 到 sys.stderr ... 03/23 23:48
今天才發現原來print可以這樣用:
f = open('txt','w')
for i in range(10):
print >> f,i
我以前都會寫成
f = open('txt','w')
a = map(str, range(10))
txt = '\n'.join(a)
f.write(txt)
f.close()
比較起來第一個好多了,跟大家分享。
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 123.193.213.133