没有sqlite美国zipcode验证python包,可以在aws lambda中使用

zipcodes的Python项目详细描述


邮政编码

python(2和3)的轻量级美国邮政编码验证包。 这个包是作为 zipcode提供的太多 功能并依赖于sqlite3,这在 平台,如aws lambda。而增加额外的 邮政编码,这个包提供邮政编码的基本功能 具有较少依赖性和最小工作逻辑的验证。

https://pepy.tech/badge/zipcodes

欢迎投稿!

安装

$ pip install zipcodes

概要

下面是这个包的预期用途以及 支持的功能。

>>>frompprintimportpprint>>>importzipcodes>>># Simple zip-code matching.>>>pprint(zipcodes.matching('77429'))[{'zip_code':'77429','zip_code_type':'STANDARD','city':'CYPRESS','state':'TX','lat':29.96,'long':-95.69,'world_region':'NA','country':'US','active':True}]>>># Handles of Zip+4 zip-codes nicely. :)>>>pprint(zipcodes.matching('77429-1145'))[{'zip_code':'77429','zip_code_type':'STANDARD','city':'CYPRESS','state':'TX','lat':29.96,'long':-95.69,'world_region':'NA','country':'US','active':True}]>>># Will try to handle invalid zip-codes gracefully...>>>print(zipcodes.matching('06463'))[]>>># Until it cannot.>>>zipcodes.matching('0646a')Traceback(mostrecentcalllast):...TypeError:Invalidcharacters,zipcodemayonlycontaindigitsand"-".>>>zipcodes.matching('064690')Traceback(mostrecentcalllast):...TypeError:Invalidformat,zipcodemustbeoftheformat:"#####"or"#####-####">>>zipcodes.matching(None)Traceback(mostrecentcalllast):...TypeError:Invalidtype,zipcodemustbeastring.>>># Whether the zip-code exists within the database.>>>print(zipcodes.is_real('06463'))False>>># How handy!>>>print(zipcodes.is_real('06469'))True>>># Search for zipcodes that begin with a pattern.>>>pprint(zipcodes.similar_to('0643'))[{'active':True,'city':'GUILFORD','country':'US','lat':41.28,'long':-72.67,'state':'CT','world_region':'NA','zip_code':'06437','zip_code_type':'STANDARD'},{'active':True,'city':'HADDAM','country':'US','lat':41.45,'long':-72.5,'state':'CT','world_region':'NA','zip_code':'06438','zip_code_type':'STANDARD'},...# remaining results truncated for readability...]>>># Use filter_by to filter a list of zip-codes by specific attribute->value pairs.>>>pprint(zipcodes.filter_by(city="WINDSOR",state="CT"))[{"zip_code":"06006","zip_code_type":"UNIQUE","city":"WINDSOR","state":"CT","lat":41.85,"long":-72.65,"world_region":"NA","country":"US","active":True},{"zip_code":"06095","zip_code_type":"STANDARD","city":"WINDSOR","state":"CT","lat":41.85,"long":-72.65,"world_region":"NA","country":"US","active":True},],>>># Arbitrary nesting of similar_to and filter_by calls, allowing for great precision while filtering.>>>pprint(zipcodes.similar_to('2',zips=zipcodes.filter_by(active=True,city='WINDSOR')))[{'active':True,'city':'WINDSOR','country':'US','lat':33.48,'long':-81.51,'state':'SC','world_region':'NA','zip_code':'29856','zip_code_type':'STANDARD'},{'active':True,'city':'WINDSOR','country':'US','lat':36.8,'long':-76.73,'state':'VA','world_region':'NA','zip_code':'23487','zip_code_type':'STANDARD'},{'active':True,'city':'WINDSOR','country':'US','lat':36.0,'long':-76.94,'state':'NC','world_region':'NA','zip_code':'27983','zip_code_type':'STANDARD'}]>>># Have any other ideas? Make a pull request and start contributing today!>>># Made with love by Sean Pianka

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
静态函数中局部变量的java垃圾收集   java向ImageView添加投掷手势   java spring引导未根据配置文件读取正确的属性   主屏幕小部件中的java自定义布局   java JSP:具有相对路径的FileReader引发FileNotFoundException   java Hibernate在集合上循环时删除会话   java无法建立到jdbc:oracle:thin:@localhost:1521:XE的连接   java我可以使用Hibernate对特定的整数大小进行验证吗?   批处理文件如何注意Java中不同语言环境中的文件名   用于IntelliJ中声纳、PMD、Findbugs和Checkstyle的Java 8   在PIG程序中找不到java类分布式文件系统   Java游戏引擎中动态ZOrdering的绘制   java处理线程工作者的多个错误   带有MariaDB驱动程序的java MySQL服务器产生日期排序错误   java终止线程的正确方法   java Android在手机睡眠时发送udp   java如何将文档添加到事务内部的Firebase集合?