看板 Python 關於我們 聯絡資訊
※ 引述《vivianCute (最可愛了啦~*)》之銘言: : 朋友是python的新手, : 有以下問題想請問版上的高手們, : 還請大家不吝賜教,感激不盡! : 由於問題內容有點長,附上Yahoo知識家的發問連結, : 麻煩大家了^^ : http://tw.knowledge.yahoo.com/question/question?qid=1608042403485 remove_lines = [ int(l) for l in sys.argv[1:] ] 這行改成 remove_lines = [ int(l) for l in open('linenum.txt').read().split() ] 就可以了。 原來的 sys.argv 是說從命令列後面讀到你要刪除的行數, 現在改成用 open() 去開啟某個你指定的檔案,然後全部 read() 出來, 之後在用 split() 切開成一個一個數字的字串,換行或是空白都可以分隔, 這樣就完成了。 這邊有入門文件 ^^ http://www.freebsd.org.hk/html/python/tut_tw/tut.html -- To iterate is human, to recurse is divine. 遞迴只應天上有, 凡人該當用迴圈.   L. Peter Deutsch -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.114.78.40