看板 Python 關於我們 聯絡資訊
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