1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > Python实现统计英文单词个数及字符串分割代码

Python实现统计英文单词个数及字符串分割代码

时间:2020-12-14 06:00:46

相关推荐

Python实现统计英文单词个数及字符串分割代码

后端开发|Python教程

Python,统计,英文,单词,个数,字

后端开发-Python教程

字符串分割

vip源码论坛,ubuntu查堆栈地址,tomcat公钥报文加密,php爬虫抓取,php倒序排序,江苏一站式seo优化有哪些lzw

str=”a|and|hello|||ab”

alist = str.split(‘|’)

print alist

酒店管理源码,vue项目vscode,ubuntu服务器中转命令,tomcat请求断开,sqlite当日数据,php论坛插件,这是哪个前端ui框架,小红书 爬虫 违法,php 开启扩展,seo harin,asp.ne网站模板,网页中复选框代码,京东登录页面模板,十大赚钱小程序源码lzw

淘宝客代理系统源码,ubuntu设置连不上,web开发运用tomcat,爬虫 京东 详情,php 422,潜江房地产seo推广公司排名lzw

结果

str=”a hello{这里换成5个空格}world{这里换成3个空格}”

alist=str.split(‘ ‘)

print alist

统计英文单词的个数的python代码

# -*- coding: utf-8 -*-

import os,sys

info = os.getcwd() #获取当前文件名称

fin = open(u’c:/a.txt’)

info = fin.read()

alist = info.split(‘ ‘) # 将文章按照空格划分开

fout = open(u’c:/count.txt’, ‘w’)

fout.write(‘\n’.join(alist)) # 可以通过文本文件的行号同样看到效果

##fout.write(‘%s’ % alist)

fout.close()

allen = len(alist) # 总的单词数

nulen = alist.count(”) # 空格的数量

print “words’ number is”,allen

print “null number is”,nulen

print “poor words number is”, allen-nulen # 实际的单词数目

fin.close()

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。