首页 > 其他 > 详细

ex17.py

时间:2016-11-19 03:35:21      阅读:252      评论:0      收藏:0      [点我收藏+]
 1 # -*- coding:utf-8 -*-
 2 from sys import argv 
 3 from os.path import exists
 4 
 5 script, from_file, to_file = argv
 6 
 7 print ("copying from %s to %s" % (from_file, to_file))
 8 
 9 # we could do these two on one line too,how?
10 in_file = open(from_file)
11 indata = in_file.read()
12 
13 print("the input fule is %d bytes long" % len(indata))  #学会使用len()函数
14 
15 print ("Does the output file exist? %r" % exists(to_file))
16 print ("Ready,hit RETURN to countinue, CTRL-C to abort.")
17 input()
18 
19 out_file = open(to_file, w)
20 out_file.write(indata)
21 
22 print("alright, all done.")
23 out_file.close()
24 in_file.close()

 

ex17.py

原文:http://www.cnblogs.com/jiangzhipeng/p/6079687.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!