擅长:python、mysql、java
<p>虽然您当然可以使用regex来解决这类问题,但我还是忍不住想,很可能有一个Python库已经为您解决了这个问题。我从来没用过这些,但只要快速搜索一下就会发现:</p>
<p><a href="https://github.com/datamade/usaddress" rel="nofollow noreferrer">https://github.com/datamade/usaddress</a></p>
<p><a href="https://pypi.python.org/pypi/postal-address" rel="nofollow noreferrer">https://pypi.python.org/pypi/postal-address</a></p>
<p><a href="https://github.com/SwoopSearch/pyaddress" rel="nofollow noreferrer">https://github.com/SwoopSearch/pyaddress</a></p>
<p>PyParsing还有一个地址示例,您可以查看:<a href="http://pyparsing.wikispaces.com/file/view/streetAddressParser.py" rel="nofollow noreferrer">http://pyparsing.wikispaces.com/file/view/streetAddressParser.py</a></p>
<p>您还可以看看前面的问题:<a href="https://stackoverflow.com/questions/9463471/is-there-a-library-for-parsing-us-addresses">is there a library for parsing US addresses?</a></p>
<p>有什么理由不能仅仅使用第三方库来解决问题吗?他说</p>
<p>编辑:他们的网址:<a href="https://github.com/pyparsing/pyparsing" rel="nofollow noreferrer">https://github.com/pyparsing/pyparsing</a></p>