编程新手,使用python3.0。你知道吗
我必须编写一个程序,为一个.txt文件输入一个文件名,读取该文件,但只读取某些字,忽略浮点和整数以及任何与另一个列表中的任何字都不匹配的字。你知道吗
基本上,我有单词列表和消息.txt. 这个程序必须通读消息.txt(文本示例:
[41.298669629999999, -81.915329330000006] 6 2011-08-28 19:02:36 Work needs to fly by ... I'm so excited to see Spy Kids 4 with the love of my life ... ARREIC)
然后它必须忽略所有数字,搜索消息中的任何单词是否与words列表中的单词匹配,然后将这些单词与hvList中的值(int)匹配。你知道吗
到目前为止,我所拥有的:(wordsList和hvList在代码的另一部分,我认为没有必要显示它来理解我正在尝试做什么(如果您确实需要它来帮助,请告诉我)
def tweetsvalues ():
tweetwList = []
tinputfile = open(tweetsinputfile,"r")
for line in tinputfile:
entries = line.split()
最后一行entries = line.split()
我猜是需要修改的。你知道吗
这是我今天早些时候作为一个非常基本的拼写检查器编写的一些代码。我想更具体地回答你的问题,但我现在没有时间。这应该可以完成你想要的。我正在打开的硬编码的.txt文件包含许多拼写正确的英语单词。请随时补充我的想法到您的工作需要,但一定要了解所有的代码,你正在使用,否则我只会阻碍你的学习,把这个代码给你。在您的情况下,您可能希望输出所有单词,而不管它们的拼写如何,在我的代码中,我只输出拼写错误的单词。有问题尽管问
是的,斯普利特是你最好的朋友。您还可以在文档中查找is方法。尽管完整的代码超出了StackOverflow的正常范围,但是您的中心工作看起来像
这可以用一种“Pythonic”的方式来完成,使用过滤器,删除标点符号等。但是,从你在帖子中的写作方式来看,我怀疑你可以从这里开始。你知道吗
相关问题 更多 >
编程相关推荐