首页 > 其他 > 详细

ex15

时间:2016-11-17 12:56:54      阅读:90      评论:0      收藏:0      [点我收藏+]
 1 # -*-coding:utf-8 -*-
 2 from sys import argv
 3 
 4 script, filename =argv  #参数赋值
 5 
 6 txt = open(filename)  #txt变量为打开文件
 7 
 8 print ("Here‘s your file %r:" % filename) #在屏幕上提示您的文件名
 9 print ("make sure your type is right?")
10 makesure = input("Y/N\n>>>>")
11 
12 if makesure == "Y":
13   print (txt.read())
14   print ("you successed!")   #打开文件并在屏幕显示阅读
15   print ("need to close the txt?")
16   closeit = input("ok/no\n>>>>")
17   if closeit == "ok":
18    txt.close()
19   else:
20    print ("read it quickly!")
21    
22 
23 elif makesure == "N":
24   print ("Type the filename again:")  #提示再次输入您的文件名
25   file_again = input("\n>>>>")  #输入您的文件名
26   txt_again = open(file_again)  # 再次定义tex_again为打开您的文件
27   print (txt_again.read())   
28   print ("you successed!") 

 

ex15

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

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