-★出爺;3 发表于 2018-8-10 08:08:35

python学习日记(笨办法) test16-11810620

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)
页: [1]
查看完整版本: python学习日记(笨办法) test16-11810620