python中的可用ups集成

ClassicUPS的Python项目详细描述


Classicups是一个Apache2许可的包装器,用于创建 运送标签并获取包裹的跟踪状态。这个图书馆不是 means包含所有ups功能,但它适用于 最常见的与运输相关的常见任务。

功能

  • 跟踪跟踪号的交货状态
  • 以gif或epl(热敏打印机)格式创建预付运费标签

安装

安装很简单:

$ pip install ClassicUPS

classicups依赖于libxml2和libxslt。在ubuntu上,包是 libxml2-devlibxslt-dev

快速启动

创建upsconnection对象,使您可以访问常见的ups方法:

fromClassicUPSimportUPSConnection# Credentials obtained from the UPS websiteups=UPSConnection(license_number,user_id,password,shipper_number,# Optional if you are not creating a shipmentdebug=True)# Use the UPS sandbox API rather than prod

检查包裹的交货日期。

tracking=ups.tracking_info('1Z12345E0291980793')printtracking.in_transitprinttracking.delivered

创建发货并将发货标签保存为gif文件:

from_addr={'name':'Google','address1':'1600 Amphitheatre Parkway','city':'Mountain View','state':'CA','country':'US','postal_code':'94043','phone':'6502530000'}to_addr={'name':'President','address1':'1600 Pennsylvania Ave','city':'Washington','state':'DC','country':'US','postal_code':'20500','phone':'2024561111'}dimensions={# in inches'length':1,'width':4,'height':9}weight=10# in lbs# Create the shipment. Use file_format='EPL' for a thermal-printer-compatible EPLshipment=ups.create_shipment(from_addr,to_addr,dimensions,weight,file_format='GIF')# Print information about our shipmentprintshipment.costprintshipment.tracking_number# Save the shipping label to print, email, etcshipment.save_label(open('label.gif','wb'))

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

推荐PyPI第三方库


热门话题
java将Scanner对象作为构造函数参数传递给UserInterface类   spring未能启动bean“subtocolWebSocketHandler”;嵌套的例外是java。lang.IllegalArgumentException:没有处理程序   Java EE应用程序中后台服务的多线程Java线程(设置守护进程和优先级)?   java Pull to refresh返回列表的第一个位置   无法将comparator类转换为java。可比的   java将json从servlet传递到dojo   JavaHibernate:将子类实例转换为超类实例   java警告调用servlet类时非法反射访问   java静态变量值   java@Entity和@embeddeble之间有什么区别   java将作业配置导入公共作业配置类(注释配置)   sql公共表表达式(以values语句开头)在java中给出错误   java在ImageJ中使用ImageProcessor   java PostgreSQL executeBatch()会随着时间的推移而变慢   java在安卓中以表格形式排列sqllite表数据?   java中SVG的swing定制呈现   java删除与另一个实体映射的实体   java何时/如何添加ListView适配器,使用back按钮恢复它?(片段)   java为什么IBinder和Binder之间的类型转换不是非法的?   java在方法参数列表中使用ArrayList或List