-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex15.py
More file actions
30 lines (23 loc) · 796 Bytes
/
Copy pathex15.py
File metadata and controls
30 lines (23 loc) · 796 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Imports argv for use in this script
from sys import argv
# Sets script and filename variables to values obtained from argv
script, filename = argv
# Sets variable txt equal to a pointer to whatever file was
# entered on the command line.
txt = open(filename)
# Prints the string with the formatted variable
print "Here's your file %r:" % filename
# Prints the content of the file contained in variable txt
print txt.read()
# Prints the string
print "Type the filename again:"
# Sets variable equal to user input
file_again = raw_input("> ")
# Sets variable equal to contents of previous user input
txt_again = open(file_again)
# Prints the content of the data contained in txt_again variable
print txt_again.read()
# Closes txt file
txt.close()
# Closes txt_again file
txt_again.close()