下面的示例是去除标点符号并将文本从冉波.txt文件。。。在
帮我把这个用空格分开
infile = open('ranbo.txt', 'r')
lowercased = infile.read().lower()
for c in string.punctuation:
lowercased = lowercased.replace(c,"")
white_space_words = lowercased.split(?????????)
print white_space_words
现在,在这个拆分之后,我怎么能找到这个列表中有多少个单词?在
^{pr2}$
使用任意长度的空白字符进行拆分。在
^{pr2}$退货
^{3}$但你也可以换一种方式:
返回
text
中所有“单词”的列表。在使用
len()
获取其长度:如果你想用新行将它们连接成一个新的字符串:
整体而言:
相关问题 更多 >
编程相关推荐