我从另一个问题中发现了以下例子: Here
它有一些类似pyparsing的代码:
from pyparsing import *
survey = '''GPS,PN1,LA52.125133215643,LN21.031048525561,EL116.898812'''
number = Word(nums+'.').setParseAction(lambda t: float(t[0]))
separator = Suppress(',')
latitude = Suppress('LA') + number
longitude = Suppress('LN') + number
elevation = Suppress('EL') + number
line = (Suppress('GPS,PN1,')
+ latitude
+ separator
+ longitude
+ separator
+ elevation)
print line.parseString(survey)
它说输出是:
^{2}$但是,我得到以下输出:
[W:(0123...), W:(0123...), W:(0123...)]
如何获得浮点输出而不是这些“W:(0123…)”值?在
谢谢!在
我升级了python和pyparsing版本,但仍然不能正常工作。然而,第二天早上它突然工作得很好。我不知道为什么,也许一夜之间的重启起了作用。不管怎样,它现在似乎工作正常。在
相关问题 更多 >
编程相关推荐