petit_herisson

导航

Exercise 15 - read file

 

from sys import argv

script, filename = argv

txt = open(filename)

print("here's your file %r:" % filename)
print(txt.read())

print("Type the filename again:")
file_again = input("> ")

txt_again = open(file_again)

print(txt_again.read())

output

D:\>python ex15.py ex15_sample.txt
here's your file 'ex15_sample.txt':
This is stuff I typed into a file.
It is really cool stuff.
Lots and lots of fun to have in here.
Type the filename again:
> ex15_sample.txt
This is stuff I typed into a file.
It is really cool stuff.
Lots and lots of fun to have in here.

 

2019-09-27

17:20:58

posted on 2019-09-27 13:21  petit_herisson  阅读(91)  评论(0)    收藏  举报