1
def save_friend(filename, friends_list):
rows = ''
strings = open(filename, 'Ur')
for c in strings:
rows += ','.join(c)
rows += '\n'
return strings.write(rows)
试图将列表(friends_list)
重写为文件(filename)
。在测试IOError: File not open for writing
时,请继续收到此错误 消息。但我以前的功能打开文件就好..python写入错误
尝试使用'w +'而不是'Ur' – enginefree 2013-03-23 04:13:08
非常感谢! – Josh123 2013-03-23 04:21:43
w +将允许他写入文件,但由于他没有将字符串设置为任何内容,它将创建一个空文件。 – eandersson 2013-03-23 04:23:15