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