跳转到主要内容

用于处理尼加拉瓜邮政编码的Python包

项目描述

postalcodes-ni

用于处理尼加拉瓜邮政编码的Python包

made-with-python made-with-python PyPI version Travis-ci GitHub version Documentation Status

快速入门

安装 postalcodes-ni

$ pip install postalcodes-ni

然后在您的项目中使用它

from postalcodes_ni import (
    get_all_municipalities_by_iso, get_all_municipalities_by_postal,
    get_municipality_by_name, get_municipality_by_postal
)

您可以在https://postalcodes-ni.readthedocs.io找到文档

此包使用以下网站的数据

用法

postalcodes_ni公开以下方法

  • get_all_municipalities_by_iso 使用ISO代码获取一个部门中的所有市镇 - 例如 MN马那瓜 部门。
  • get_all_municipalities_by_postal 使用邮政编码获取一个部门中的所有市镇 - 例如 10000马那瓜 部门。
  • get_municipality_by_name 使用名称获取一个特定的市镇 - 例如 阿尔塔格拉西亚里瓦斯 部门。
  • get_municipality_by_postal 用于通过邮编获取特定市镇 - 例如,使用邮编 48800 来获取来自 里瓦斯 部门的 阿尔塔格拉西亚 市镇。

示例

首先,您需要导入您想要使用的函数

from postalcodes_ni import (
    get_all_municipalities_by_iso, get_all_municipalities_by_postal,
    get_municipality_by_name, get_municipality_by_postal
)

要获取一个部门中的所有市镇,请使用以下方法

>>> # Get all the municipalities in Carazo department using iso code
>>> get_all_municipalities_by_iso('CA')
[('Jinotepe', 45000), ('Dolores', 46100), ('El Rosario', 46200), ...]

>>> # Get all the municipalities in Carazo department using postal code
>>> get_all_municipalities_by_postal(45000)
[('Jinotepe', 45000), ('Dolores', 46100), ('El Rosario', 46200), ...]

要获取一个部门中的特定市镇,请使用以下方法

>>> # Get a municipality using his name
>>> get_municipality_by_name('nindiri')
('Nindirí', 42200)

>>> # Get a municipality using his postal code
>>> get_municipality_by_postal(42500)
('Catarina', 42500)

运行测试

代码是否真的可行?

$ source env/bin/activate
(env) $ pip install -r requirements_dev.txt
(env) $ make test-all

历史

1.0.0 (2019-03-27)

  • 首次发布在 PyPI 上。

项目详情


下载文件

下载适用于您的平台的文件。如果您不确定选择哪个,请了解有关 安装包 的更多信息。

源代码分发

postalcodes_ni-1.2.0.tar.gz (26.8 kB 查看哈希)

上传时间 源代码

构建分发

postalcodes_ni-1.2.0-py2.py3-none-any.whl (16.8 kB 查看哈希)

上传时间 Python 2 Python 3

由以下支持