Re: [問題] 如何刪除特定符號

看板Python作者 (Naruto)時間14年前 (2010/12/07 18:39), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
def num(): fin = open ("testdata.txt") for line in fin: word = line.strip() word = line.split(' ') import re pun_replace = re.compile("[!.'?,]+") word = pun_replace.sub("",line) q = ''.join(word) print q num() 如果我現在要把全部的字都黏在一起...像pig head 變成pighead,為什麼我用 ''.join(word)沒辦法把字年在一起呢? 我在網路上找到可以用空白字串把它們黏在一起 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.212.197
文章代碼(AID): #1C_Wx85R (Python)
文章代碼(AID): #1C_Wx85R (Python)