您的位置:首页 > 编程语言 > Python开发

读写文件,python. learn python the hard way

2017-03-12 08:54 309 查看
#coding=utf-8
poem = "\t I'm trying to writ this into my file,,ooo"

def method_one():
f = open('new.txt', 'w')  #open new.txt as file 确认在终端,你已经cd进入了文件所在文件夹。否则Open不出来
f.write(poem) #write poem into f
f.close() #close my file

def method_two():
from sys import argv
script, new = argv
f = open(new, 'w')
f.write(poem)
f.close()

method_two()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python 终端 utf-8