看板 CodeJob 關於我們 聯絡資訊
貼一下,python的版本 不知道還有沒有更精簡的方法 不過也真的是一頓飯就很多了,沒幾分鐘的code #--------Code Start---------------------- inputfd = file("testdata.txt", 'r') outputfd = file("testdata_result.txt", 'w') while 1: line = inputfd.readline() if not line: break line = line.replace('\r', '') line = line.replace('\n', '') line = line.split(' ') for x in line: try: outputfd.write("%s\n" % int(x,10)) except: continue inputfd.close() outputfd.close() #--------Code End---------------------- FYI. -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 221.120.66.203
deo2000:板上都好強! 雖然我覺得不難,但還是要寫很久 12/02 09:18
※ 編輯: leeraphael 來自: 60.251.231.82 (12/02 09:36)
litleaf:還是 python 看起來比較親切 像在說話一樣 12/02 09:48
LaPass:Java: 12/02 11:21
LaPass:new 讀取檔案("test.txt").取得內容().再把空格換成換行(). 12/02 11:21
LaPass:把檔案存回去(); 12/02 11:22
LaPass: ※可執行 12/02 11:22
LaPass:linux好像可以打個指令應該就能直接取代文擋中的字了 12/02 11:25