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 id 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 id 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

Guess you like

Origin www.cnblogs.com/petitherisson/p/11597410.html