永发信息网

小白求python 为啥打印不出来?

答案:2  悬赏:10  手机版
解决时间 2021-03-22 04:35
from sys import argv
from os.path import exists # This returns True if a file exists.

script, from_file, to_file =argv

print "Copying from %s to %s" % (from_file, to_file)

# we could do these two on one line, how?
in_file = open (from_file)
indata = in_file.read ()

print "The input file is %d bytes long" % len(indata)

print "Does the output file exist? %r" % exists (to_file)
print "Ready, hit RETURN to continue, CTRL-C to abort."
raw_input()

out_file = open (to_file, "w")
out_file.write (indata)

print "Alright, all done."

out_file.close () # don't forgot ()!
in_file.close ()

在powershell测试之后出现:

> python "lesson 17.py" "lesson 17s.txt" "lesson 17s2.txt"
Copying from lesson 17s.txt to lesson 17s2.txt
The input file is 21 bytes long
Does the output file exist? False
Ready, hit RETURN to continue, CTRL-C to abort.
Traceback (most recent call last):
File "lesson 17.py", line 16, in
最佳答案
你用raw_input要自己输入,但是你按了CTRL+C,自然会抛出个异常。
全部回答
这个没关系吧,其实python自带的idle也可以,你用notepad也行,都好用
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
单选题下列植被类型中,被称为地球肺的是A.草
父母离婚孩子多少岁就可以申请独自生活?几岁
婚宴敬酒,有20多桌,怎样能少喝点?
Excel 为什么分列后日期会改变
翱翔辅导地址在哪,我要去那里办事
单选题能说明氧的非金属性比硫强的是()A.硫
苹果电脑装系统osx输入无线网密码时就卡怎么
考育婴师需要学习什么
205x0.18=多少并列竖式
成都和重庆相比到底哪个城市更好?
嵌在门上的内嵌式的玻璃能换吗
单选题YoucangotoShanghaitrain.A.inB.
木瓜奇迹积分有什么用,全民奇迹元素之心战士
学吧课堂怎么取消绑定qq
重庆老村口特色石磨豆腐鱼我想知道这个在什么
推荐资讯
今年秋季有什么太阳镜款式是比较好看的?
一个长方体的棱长之和是64cm,它的长是8cm,
单选题我国省、县两级人大代表的任期分别是A.
天津华泰监理怎么样 求解
端午节有哪些活动啊
有志者事竟成的意思,谈谈你对“有志者事竟成
基于P2P的网络聊天工具设计与实现,用Java开
单选题对下列句中破折号作用的解释,错误的一
小芒果怎么剥皮,如何快速剥芒果皮
耗油可以用油炸吗
1384383838438是不是骂人一三八死三八三八三
单选题Kevincanspeak________.A.ChinaB.Brazi
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?