本文实例讲述了python保存字符串到文件的方法。分享给大家供大家参考。具体实现方法如下:
?
1 2 3 4 5 def save(filename, contents): fh = open(filename, 'w') fh.write(contents) fh.close() save('file.name', 'some stuff')希望本文所述对大家的Python程序设计有所帮助。
本文实例讲述了python保存字符串到文件的方法。分享给大家供大家参考。具体实现方法如下:
?
1 2 3 4 5 def save(filename, contents): fh = open(filename, 'w') fh.write(contents) fh.close() save('file.name', 'some stuff')希望本文所述对大家的Python程序设计有所帮助。
手机看新闻
微信扫描关注