这是字数统计程序。怎么能让它变得更简单呢?在
import re
from collections import Counter
with open('C:\Data\test.txt') as f:
passage = f.read()
words = re.findall(r'\w+', passage)
cap_words = [word.upper() for word in words]
word_counts = Counter(cap_words)
继续获取此错误消息:
^{pr2}$
Tags:
使用原始字符串或用
\
对每个\
进行转义。这是必需的,因为没有它,'\t'
将转换为制表符空间:示例:
^{pr2}$相关问题 更多 >
编程相关推荐