讀寫文件,python. learn python the hard way

#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()
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章