exercise15 读取文件
来源:互联网 发布:其竟以此而殒其生乎 编辑:程序博客网 时间:2024/06/01 19:51
运行文件ex15.py
ex15_sample.txt //记事本的内容
This is stuff I typed into a file.
It is really cool stuff.
Lots and lots of fun to have in here.
from sys import argv
script, filename=argv
txt=open(filename)
print "Here is your file %r:" %filename
print txt.read()
print "type the filename again:"
filename_again=raw_input(">") # raw_input后面若为显示的内容,要加上引号!!!
txt_again=open(filename_again)
print txt_again.read()
$ python ex15.py ex15_sample.txt
Here's your file 'ex15_sample.txt':
This is stuff I typed into a file.
It is really cool stuff.
Lots and lots of fun to have in here.
Type the filename again:
> ex15_sample.txt
This is stuff I typed into a file.
It is really cool stuff.
Lots and lots of fun to have in here.
Here's your file 'ex15_sample.txt':
This is stuff I typed into a file.
It is really cool stuff.
Lots and lots of fun to have in here.
Type the filename again:
> ex15_sample.txt
This is stuff I typed into a file.
It is really cool stuff.
Lots and lots of fun to have in here.
最后需要用close()关闭文件
0 0
- exercise15 读取文件
- linux exercise15
- 文件读取(读取图片)
- 读取文件
- 读取文件
- 文件读取
- 文件读取
- 文件读取
- 读取文件
- 读取文件
- 读取文件
- 读取文件
- 文件读取
- 读取文件
- 文件读取
- 文件读取
- 读取文件
- 读取文件
- win7计算器功能详解
- SIOCADDRT: File exists
- Java读取Excel内容
- LeetCode 450. Delete Node in a BST
- android EditText 自动换行 设置
- exercise15 读取文件
- C语言基础之结构体、共用体、枚举、类型定义typedef
- struts2 校验器——字段表达式校验器(fieldexpression)(内建校验器)
- Android常见问题集锦
- Android getDecorView用途——屏幕截图
- 实现一个简单的拦截器
- redis与memcache的优缺点
- nodejs群聊私聊
- Struts2-表单验证的两种方式