python deepcopy源码_《笨办法学python》源码 Ex15.py

# 命令行参数名为"ex_15_sample.txt" txt文本内容如下:

--------------------------------------

This is stuff I typed into a file.

It is really cool stuff.

Lots and lots of fun to have in here.

*************************************

I am huanghuan.

today is 2013-08-14.

I am very happy today.

what about you?

-------------------------------------

#-------------------------------------------------------------------------------

# Name: ex_15.py

# Purpose: 读取txt文件.

# open() 打开文件

# read() 读取文件

# close() 关闭文件.

# Author: huanghuan

#

# Created: 14-08-2013

# Copyright: (c) huanghuan 2013

# Licence:

#-------------------------------------------------------------------------------

from sys import argv

# 方式1.

# 命令行参数名为"ex_15_sample.txt"

script, file_name1 = argv

# 打开文本.

txt1 = open(file_name1)

print "here's your file %r:" % file_name1

# 调用read()读出文本内容.

print txt1.read()

txt1.close()

#---------------------------------------

"""

# 方式2.

print "Input the file name again:"

file_name2 = raw_input("> ")

# 打开文本.

txt2 = open(file_name2)

# 读入文本

print txt2.read()

"""

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值