作者david8811 (Naruto)
看板Python
标题Re: [问题] 如何删除特定符号
时间Tue Dec 7 18:39:00 2010
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