国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

Python3寫入文件常用方法實(shí)例分析

2020-02-23 01:20:22
字體:
供稿:網(wǎng)友

本文實(shí)例講述了Python3寫入文件常用方法。分享給大家供大家參考。具體如下:

''''' Created on Dec 18, 2012 寫入文件 @author: liury_lab ''' # 最簡(jiǎn)單的方法all_the_text = 'hello python'open('d:/text.txt', 'w').write(all_the_text)all_the_data = b'abcd1234'open('d:/data.txt', 'wb').write(all_the_data)# 更好的辦法file_object = open('d:/text.txt', 'w') file_object.write(all_the_text)file_object.close()# 分段寫入list_of_text_strings = ['hello', 'python', 'hello', 'world']file_object = open('d:/text.txt', 'w')for string in list_of_text_strings:  file_object.writelines(string)list_of_text_strings = ['hello', 'python', 'hello', 'world']file_object = open('d:/text.txt', 'w')file_object.writelines(list_of_text_strings)

希望本文所述對(duì)大家的Python程序設(shè)計(jì)有所幫助。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 留坝县| 安庆市| 乾安县| 甘泉县| 青阳县| 贺兰县| 舟曲县| 西平县| 松滋市| 广丰县| 铅山县| 乌拉特中旗| 湖南省| 崇州市| 东平县| 明溪县| 朔州市| 绥江县| 武冈市| 丹江口市| 锡林郭勒盟| 澄城县| 仙居县| 双柏县| 阿荣旗| 商河县| 台州市| 龙南县| 山东省| 屏东县| 太和县| 兴城市| 临汾市| 孟连| 南华县| 惠来县| 信丰县| 江山市| 丰台区| 论坛| 镇沅|