没有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中读取/打开文本文件   java为什么这段代码不适用于CodeEval?   java如何将日历转换为JSON   从txt文件中读取字符串并将其存储到java中的字符数组中   字符编码Java ResourceBundles umlauts搞砸了   java为什么hashmap会根据总大小而不是填充的存储桶调整大小   java如何将Excel单元格中的数字字符串读取为字符串(而不是数字)?   java Guava的LocalCache无法使用,为什么?   java有没有办法强制JVM在单个处理器或内核上运行   java Eclipse不安装软件   将字节转换为java字符串(可能是汉字)   Java正则表达式:提取函数名   JavaTestNG:如何从多个类中指定测试方法顺序?