-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex16.py
More file actions
38 lines (24 loc) · 672 Bytes
/
ex16.py
File metadata and controls
38 lines (24 loc) · 672 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
31
32
33
34
35
36
37
38
#This is a test script
from sys import argv
script, filename = argv
print "We are going to erase %r" % filename
print "Press control C to abort"
print "Else Return"
raw_input("?")
print "Openning File..."
target = open(filename, 'w')
print "Trunacting the file, Goodbye!"
target.truncate()
print "Now I am going to ask you for three lines"
line1 = raw_input("What is your name?")
line2 = raw_input("Where do you live?")
line3 = raw_input("What do you do?")
print "Now we will write to file"
target.write(line1)
target.write("\n")
target.write(line2)
target.write("\n")
target.write(line3)
target.write("\n")
print "Finally we close the file"
target.close()