在Python(最好是py3k)上使用sscanf?

2024-01-01

我见过这个问题 https://stackoverflow.com/q/2175080/309483,但我遇到了问题顶级解决方案 https://hkn.eecs.berkeley.edu/~dyoo/python/scanf/。 例如:

>>> scanf.sscanf("\"test\"","\"%s\"")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "scanf.py", line 393, in sscanf
    return bscanf(CharacterBufferFromIterable(inputString), formatString)
  File "scanf.py", line 414, in bscanf
    return parser(buffer)
  File "scanf.py", line 577, in __call__
    raise IncompleteCaptureError(e, tuple(results))
scanf.IncompleteCaptureError: (FormatError('" != ',), ('test"',))
>>> 

我究竟做错了什么?这不应该起作用吗?


我包裹了解析模块 http://pypi.python.org/pypi/parse:

from parse import parse
parse("\"%s\"".replace("%s","{}"), "\"test\"").fixed
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在Python(最好是py3k)上使用sscanf? 的相关文章

随机推荐