lightweight python library to query city/state name by zip code?

前端 未结 4 922
孤城傲影
孤城傲影 2021-02-14 08:20

Pretty simple here, I\'m looking for a lightweight library that will allow me to lookup a city/state pairing for a given zip code. I am using django FWIW. Thanks in advance.

4条回答
  •  无人共我
    2021-02-14 08:43

    Try pyzipcode. An example from the home page:

    >>> from pyzipcode import ZipCodeDatabase
    >>> zcdb = ZipCodeDatabase()
    >>> zipcode = zcdb[54115]
    >>> zipcode.zip
    u'54115'
    >>> zipcode.city
    u'De Pere'
    >>> zipcode.state
    u'WI'
    >>> zipcode.longitude
    -88.078959999999995
    >>> zipcode.latitude
    44.42042
    >>> zipcode.timezone
    -6
    

提交回复
热议问题