python写文件
来源:互联网 发布:长沙java培训 编辑:程序博客网 时间:2024/05/17 23:24
#!/usr/bin/python
# Filename: using_file.py
poem = '''/
Programming is fun
When the work is done
if you wanna make your work also fun:
use Python!
'''
f = file('poem.txt', 'w') # open for 'w'riting 'w'不追加 'a+'是追加写(貌似) /r/n换行
f.write(poem) # write text to file
f.close() # close the file
f = file('poem.txt')
# if no mode is specified, 'r'ead mode is assumed by default
while True:
line = f.readline()
if len(line) == 0: # Zero length indicates EOF
break
print line,
# Notice comma to avoid automatic newline added by Python
f.close() # close the file
- python 写文件
- python 写xml文件
- python写文件
- python 写文件换行
- python写文件
- Python 写文件
- python 写文件
- python写文件出错
- python写utf8文件
- python写csv文件
- Python写Excel文件
- python写csv文件
- python 写 yml文件
- python 写yml文件
- Python -- 写Excel文件
- python写csv文件
- Python文件写操作
- Python 写文件
- ADT OO OB 的区别
- Java的@Override注解问题
- 批量写sql
- 删除sqlserver挂起
- ubuntu10.04将php5.3降级为php5.2方法(sh文件内容)
- python写文件
- ArrayList的深浅拷贝。
- ubuntu 10.04 ftp的使用
- ubuntu 使用笔记
- python截串
- 教研科岗位职责
- python获取访问者ip
- shell脚本的制作
- 资源重复错误