首页 \ 问答 \ excel统计英文词频

excel统计英文词频

我有数篇英文文献,字数共计10万,我想统计这几篇文献中所有英文单词出现的词频,请问用excel什么功能可以实现,如果需要使用VBA的话,若能给出算法愿追加50分。
更新时间:2023-10-10 21:10

最满意答案

遍历file的每一行line,生成新的list,line for line in ...是为了对遍历的每一行做处理的,比如
[line.strip() for line in file()]  这样生成的list中的每一个line都是经过了strip操作的,或者我要取每一行的前面几个字符就是  [line[:3] for line in file()],只不过你这个地方是没有做任何处理。

其他回答

因为这是个变量名啊,你当然随便起什么名字都可以。

相关问答

更多
  • 遍历file的每一行line,生成新的list,line for line in ...是为了对遍历的每一行做处理的,比如 [line.strip() for line in file()] 这样生成的list中的每一个line都是经过了strip操作的,或者我要取每一行的前面几个字符就是 [line[:3] for line in file()],只不过你这个地方是没有做任何处理。
  • python split()默认以空格分割 例如 你的trainfile的一行内容为 1 2 3 那么userid,itemid,record=line.split( ) 就line.split( )先得到 1 2 3 然后再把 这三个值 依次赋给userid,itemid,record 这三个变量
  • 不要以这种方式循环访问文件。 而是使用for循环。 for line in f: vowel += sum(ch.isvowel() for ch in line) 事实上,您的整个计划只是: VOWELS = {'A','E','I','O','U','a','e','i','o','u'} # I'm assuming this is what isvowel checks, unless you're doing something # fancy to check if 'y' is a ...
  • 以下是以下原因之一: with open('filename.txt') as fp: for line in fp: print line 我们都被CPython用于垃圾收集的相对确定性的引用计数方案所迷惑。 其他的,假设Python的实现并不一定会在足够快的情况下关闭文件with如果他们使用其他方法来回收内存,那么没有with块。 在这样的实现中,如果您的代码比垃圾收集器在孤立的文件句柄上调用finalizer更快地打开文件,则可能会从操作系统中获取“太多的文件打开”错误。 通 ...
  • current_line + = current_line扩展为 current_line = current_line + current_line 因此,让我们看看你做了什么,扩展它(我们将忽略打印语句)。 current_line = 1 current_line = current_line + current_line # (1 + 1 = 2) #current_line = 2 current_line = current_line + current_line # (2 + 2 = 4) ...
  • 从iPython控制台,你只需要做(假设文件可以在sys.path访问 - 这将包括CWD): In [1]: import movie_analysis 然后,它将运行您的文件,并输出该shell中的所有内容,就像您通过双击运行它一样。 From the iPython console, you'd just do (assuming file is accessible in sys.path- this would include the CWD): In [1]: import movie_ana ...
  • self.file是一个迭代器,只能使用一次。 这意味着在你的function_a迭代它之后,不可能在function_b使用它。 我认为一个好的解决方案是将文件存储在列表中,即 def __init__(self, fileName): with open(fileName, 'r') as f: self.file_list = f.readlines() 这应该工作,如果文件不是很大,否则你也可以用f.seek(0)设置文件指针到文件的开头。 self.file is an ...
  • 可能不是最优雅的解决方案,但它的工作原理: with open('fil') as f_in: with open('abc.txt', 'w') as abc, \ open('xyz.txt', 'w') as xyz, \ open('ttt.txt', 'w') as ttt: lines = f_in.read().split('\n\n') for line in lines: if ...
  • 对于简单的情况,是的,两级with和for是惯用的。 对于缩进成为问题的情况,这里与Python中的任何其他地方一样,惯用的解决方案是找到一些东西分解成一个函数。 你可以编写包装来帮助它。 例如,这是解决您使用的一些问题的简单方法(例如,即使在最好的情况下,文件在完成循环后仍然存在,直到范围结束 - 可能是几天之后,或者永远不会,如果范围是主事件循环或生成器或其他东西......): def with_iter(iterable): with iterable: yield from ...
  • 您可以通过迭代文件对象本身来遍历Python中的文件对象中的行: for line in f: copy.write(line) 从文件对象的文档 : 读取行的另一种方法是循环访问文件对象。 这是高效的内存,快速,并导致更简单的代码: >>> for line in f: print line, You can iterate over lines in a file object in Python by iterating over the file object itsel ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)