<filename>file_and_io/write.py
#!/usr/bin/env python2
# -*- coding: UTF-8 -*-
 
# 打开一个文件
fo = open("foo.txt", "w")
fo.write( "www.runoob.com!\nVery good site!\n")
 
# 关闭打开的文件
fo.close()
<filename>file_and_io/write.py
#!/usr/bin/env python2
# -*- coding: UTF-8 -*-
 
# 打开一个文件
fo = open("foo.txt", "w")
fo.write( "www.runoob.com!\nVery good site!\n")
 
# 关闭打开的文件
fo.close()
#!/usr/bin/env python2 # -*- coding: UTF-8 -*- # 打开一个文件 # 关闭打开的文件