
python
李白星河
nlp算法工程师
展开
-
python如何统计出txt文件有多少行内容?
filename = “F:\python工程\python02\wordcount.txt”myfile = open(filename)lines = len(myfile.readlines())print(“There are %d lines in %s” % (lines, filename))原创 2019-09-28 19:53:21 · 12962 阅读 · 0 评论 -
python统计出wordcount.txt文件中每个单词的个数
print( collections.Counter( re.findall( ‘\w+’ ,open( ‘wordcount.txt’ ).read( ) ) ) )原创 2019-09-28 20:31:08 · 1306 阅读 · 0 评论