python显示句子长度_如何从文本fi计算python2.7中的平均单词和句子长度

在过去的两个星期里,我一直在想你能帮忙吗。在

我试图从文本文件中计算平均单词长度和句子长度。我只是不知道该怎么办。我刚开始使用在主文件中调用的函数。在

我的主文件是这样的import Consonants

import Vowels

import Sentences

import Questions

import Words

""" Vowels """

text = Vowels.fileToString("test.txt")

x = Vowels.countVowels(text)

print str(x) + " Vowels"

""" Consonats """

text = Consonants.fileToString("test.txt")

x = Consonants.countConsonants(text)

print str(x) + " Consonants"

""" Sentences """

text = Sentences.fileToString("test.txt")

x = Sentences.countSentences(text)

print str(x) + " Sentences"

""" Questions """

text = Questions.fileToString("test.txt")

x = Questions.countQuestions(text)

print str(x) + " Questions"

""" Words """

text = Words.fileToString("test.txt")

x = Words.countWords(text)

print str(x) + " Words"

我的一个函数文件是这样的:

^{pr2}$

我想知道如何计算单词长度作为我导入的函数?我试着使用其他一些线程,但它们不适合我。在

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值