Re: [問題] 如何刪除特定符號
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
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):
Python 近期熱門文章
PTT數位生活區 即時熱門文章