手记

python学习日记(笨办法) test16

test16测试代码

#-*- coding: utf-8 -*-

from sys import argv

 

script , filename = argv

print  "We're gogning to erase %r ."  %  fliename

print  "If you don't want that, hit CTRL-C(^C)."

print  "If you want that ,hit RETURN."

 

#打开文件

target=open (filename,'w') 

 

#清空文件

target.truncate()

 

#输入三行内容

line1 = raw_input("line 1 :")

line2 = raw_input("line 2 :")

line3 = raw_input("line 3 :")

 

#将上面三行内容写入文件

target.write(line1)

target.write("\n")

target.write(line2)

target.write("\n")

target.write(line3)


0人推荐
随时随地看视频
慕课网APP