我试图用pyparsing扫描一个文件。pyparsing中有一个名为scanString的方法,它确实存在
>>> name = pp.Word(pp.alphas)
>>> text = "**** Farcical aquatic ceremony"
>>> for result, start, end in name.scanString(text):
... print "Found {0} at [{1}:{2}]".format(result, start, end)
...
Found ['Farcical'] at [5:13]
Found ['aquatic'] at [14:21]
Found ['ceremony'] at [23:31]
但我想扫描一个文本文件中的单词在一个句子。上面的扫描字符串扫描句子中单词所在的位置。有没有扫描文件的方法?或者,扫描字符串是否只和上面一样工作?在
目前没有回答
相关问题 更多 >
编程相关推荐