Python编程从入门到实践~文件写入
生活随笔
收集整理的這篇文章主要介紹了
Python编程从入门到实践~文件写入
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
#寫(xiě)入文件
filename = './data/programming.log'
with open(filename, 'w') as file_object:file_object.write('I love programming.\n')file_object.write('I love creating new games.\n')#附加到文件
filename = './data/programming.log'
with open(filename, 'a') as file_object:file_object.write('I aslo love finding meaning in large datasets.\n')file_object.write('I love creating apps that can run in a brower.\n')
總結(jié)
以上是生活随笔為你收集整理的Python编程从入门到实践~文件写入的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Replace Array with O
- 下一篇: python range 步长为负数_P