Python中Correios的API
项目描述
API Correios
============
安装
------------
如果您有 _setuptools_,可以使用
$ easy_install -U pycorreios
否则,您可以从[GitHub][git]下载源代码并运行
$ python setup.py install
[git]: https://github.com/avelino/pycorreios "PyCorreios"
示例
--------
pyCorreios代码的一些简单示例
```python
from pycorreios import Correios
# 使用字典参数 - 字段顺序无关紧要
fields = {"cod": Correios().SEDEX,
"GOCEP": "44001535",
"HERECEP": "03971010",
"peso": "2",
"formato": "1", # 箱子/包裹
"comprimento": "18",
"altura": "8",
"largura": "24",
"diametro": "12"}
test = Correios().frete(**fields) # 记得用**调用
# 或者使用位置参数 - 与上面相同的结果
test = Correios().frete(Correios().SEDEX,'44001535','03971010',2,1,18,8,24,12)
if test['Erro'] != '0'
print '发生错误! :('
print test['Erro']
print test['MsgErro']
else
print "价值: R$%s\n交付期限:%s" % (test['Valor'],test['PrazoEntrega'])
other_test = Correios().cep('03971010')
for tag_name in other_test.keys()
print tag_name + ': ' + other_test[tag_name]
```
============
安装
------------
如果您有 _setuptools_,可以使用
$ easy_install -U pycorreios
否则,您可以从[GitHub][git]下载源代码并运行
$ python setup.py install
[git]: https://github.com/avelino/pycorreios "PyCorreios"
示例
--------
pyCorreios代码的一些简单示例
```python
from pycorreios import Correios
# 使用字典参数 - 字段顺序无关紧要
fields = {"cod": Correios().SEDEX,
"GOCEP": "44001535",
"HERECEP": "03971010",
"peso": "2",
"formato": "1", # 箱子/包裹
"comprimento": "18",
"altura": "8",
"largura": "24",
"diametro": "12"}
test = Correios().frete(**fields) # 记得用**调用
# 或者使用位置参数 - 与上面相同的结果
test = Correios().frete(Correios().SEDEX,'44001535','03971010',2,1,18,8,24,12)
if test['Erro'] != '0'
print '发生错误! :('
print test['Erro']
print test['MsgErro']
else
print "价值: R$%s\n交付期限:%s" % (test['Valor'],test['PrazoEntrega'])
other_test = Correios().cep('03971010')
for tag_name in other_test.keys()
print tag_name + ': ' + other_test[tag_name]
```
项目详情
关闭
pycorreios-0.1.2.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 71776aa87ea7e1a2e2f175cccf5765dc6d10f48a10ad0b0b6b5d9228a0ce748e |
|
MD5 | 57db48d357b0b9d8c5128f17bf6cf9f9 |
|
BLAKE2b-256 | 1cbd91b7207a807fe16ceb7c3f631cb5e0f0fde8a3f9d0bd3e8720f1c8bf4699 |