Re: [討論] 修改CSV格式 請問這樣值多少錢?

看板CodeJob作者 (leeraphael)時間14年前 (2011/12/02 09:17), 編輯推噓4(403)
留言7則, 3人參與, 最新討論串6/12 (看更多)
貼一下,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

12/02 09:18, , 1F
板上都好強! 雖然我覺得不難,但還是要寫很久
12/02 09:18, 1F
※ 編輯: leeraphael 來自: 60.251.231.82 (12/02 09:36)

12/02 09:48, , 2F
還是 python 看起來比較親切 像在說話一樣
12/02 09:48, 2F

12/02 11:21, , 3F
Java:
12/02 11:21, 3F

12/02 11:21, , 4F
new 讀取檔案("test.txt").取得內容().再把空格換成換行().
12/02 11:21, 4F

12/02 11:22, , 5F
把檔案存回去();
12/02 11:22, 5F

12/02 11:22, , 6F
※可執行
12/02 11:22, 6F

12/02 11:25, , 7F
linux好像可以打個指令應該就能直接取代文擋中的字了
12/02 11:25, 7F
文章代碼(AID): #1Es2SUbA (CodeJob)
討論串 (同標題文章)
完整討論串 (本文為第 6 之 12 篇):
文章代碼(AID): #1Es2SUbA (CodeJob)