Python编程——IO(输入输出)
来源:互联网 发布:大文豪曼因斯坦知乎 编辑:程序博客网 时间:2024/05/12 18:46
--START--
#-*- coding=utf-8 -*-#io: file#create, read, write, delete, etc.poem = '''\Programming is funWhen the work is doneif you wanna make your work also fun:use Python!'''f = file('poem.txt', 'w') #open for 'w'ritingf.write(poem) # write text to filef.close() # close the filef = file('poem.txt') # if no mode is specified, 'r'ead mode is assumed by defaultwhile True:line = f.readline()if len(line) == 0: # 0 length indicates EOFbreakprint line, # Notice comma to avoid automatic newline added by Pythonf.close() # close the file'''summary:1)文件的打开模式:读模式('r')、写模式('w')、追加模式('a')2)文件方法:file()read()readline() : readline方法读文件的每一行,方法返回包括行末换行符的一个完整行write()close()技巧:1)在print语句上使用逗号来消除自动换行'''
--END--
0 0
- Python编程——IO(输入输出)
- IO编程——文件输入输出
- IO编程——文件输入输出
- Python学习笔记(二)——IO输入输出
- Python输入输出(IO)
- Python中的输入输出(IO)
- python的IO输入输出
- Python IO编程——学习笔记
- python学习——IO编程
- Python学习笔记——IO编程
- 传智播客——IO:输入输出流
- 输入输出处理(IO)(备忘)——下
- 黑马程序员——IO/输入输出
- Java——IO(输入输出流)
- IO流——字符流输入输出
- IO流——字节流输入输出
- 黑马程序员—IO输入输出流
- java基础—8.IO输入输出流
- sublime配置全攻略
- 同域jQuery(跨)iframe操作DOM(实例讲解)
- wpf 在 AddNew 或 EditItem 事务过程中不允许“DeferRefresh”。
- SIP协议压缩方案-SIP二进制化实现
- JQUERY dialog的用法详细解析
- Python编程——IO(输入输出)
- awg线规,直径,面积,电流对照
- 安卓开发-Activity中finish() onDestroy() 和System.exit()的区别
- 看看baidu是如何AJAX跨域的
- PHP SPL笔记
- API Guide--UI Interface--Styles and Themes
- eclipse快捷键
- python 调用mysql存储过程返回结果集
- 51 IAP说明