当前位置:妙知谷 >

游戏数码 >电脑 >

Python读和写

Python读和写

Python读写文件

操作方法

(01)先在cmd,打开IDLE

Python读和写

(02)创建文件并写入文字输入代码fp=open("","wb")e("I am a worker.nI am happy.")

Python读和写 第2张

(03)在python安装目录里果真发现

Python读和写 第3张

(04)打开查看一下,确实有文字

Python读和写 第4张

(05)读出中的文字输入代码fo=open("","r")for line in fo:print line

Python读和写 第5张

(06)发现打印出来的文字中间有空行,去除空行操作fo=open("","r")for line in fo:print line,

Python读和写 第6张

(07)以上就是Python读和写文件的简单操作。

特别提示

Python安装好

书写代码在英文状态下,不然报错

标签: python
  • 文章版权属于文章作者所有,转载请注明 https://miaozhigu.com/zh-sg/sm/diannao/4mvym0.html