原博文
2013-07-24 09:55 −
1.读文件,通过正则匹配 1 def statisticWord(): 2 line_number = 0 3 words_dict = {} 4 with open (r'D:\test\test.txt',encoding='utf-8') as a_file: 5 ...
0
6657
相关推荐
2016-06-24 14:05 −
根据一篇英文文章统计其中单词出现最多的10个单词。 # -*- coding: utf-8 -*-import urllib2import refrom collections import Counter '''007之雷霆谷 You Only Live Twice',可以从http://nove...
2016-01-15 10:38 −
# -*- coding:utf-8 -*- #author:V def tol (file1,gui): #写一个方法,定义文件,or 匹配规则 import re patt = re.compile(gui) #print(type(patt)) f = open(file1,'...
0
3922
2017-10-26 09:59 −
.python统计文本中每个单词出现的次数: #coding=utf-8 __author__ = 'zcg' import collections import os with open('abc.txt') as file1:#打开文本文件 str1=file1.read().sp...
0
19120
2018-03-12 23:23 −
# coding: utf-8 # In[1]: import collections str = "Be slow to promise and quick to perform" # 按空格切割 str_split = str.split(' ') # In[2]: str_spl...
0
3135
2016-09-28 17:19 −
一、方案 方法一: (1)cat file|sed 's/[,.:;/!?]/ /g'|awk '{for(i=1;i<=NF;i++)array[$i]++;}END{for(i in array) print i,array[i]}' #其中file为要操作的文件,sed中/...
2018-11-22 18:42 −
package com.java_Test; import java.io.File; import java.util.HashMap; import java.util.Iterator; import java.util.Scanner; import java.util.Set; pu...
2013-04-23 13:29 −
private void textBox1_TextChanged(object sender, EventArgs e) { textBox2.Text = getWordSum(textBox1.Text).ToString(); } private in...
2019-06-07 15:30 −
1 #include
2 3 int main(void)
4 {
5 char ch;
6 int start;
7 int count;
8 9 ch = getchar();
10 count = 0;
11 /*单词...
2016-01-30 11:49 −
最近在看shell中有个题目为统计单词的个数,使用了awk功能,代码如下 #!/bin/bash if [ $# -ne 1 ];then echo "Usage:basename $0 filename" exit 1 fi filename=$1 egrep -o "[a-zA-Z]+" ...