首页 > 代码库 > ex17.py
ex17.py
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 =http://www.mamicode.com/ 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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。