警察api的python客户端库

police-api-client的Python项目详细描述


用于Police API的python客户端。支持Python2.6、2.7、3.2、3.3和 3.4条。

安装

使用pip

安装police api客户端
pip install police-api-client

用法

police api不需要身份验证,因此不需要设置:

>>> from police_api import PoliceAPI
>>> api = PoliceAPI()

检索力和邻里数据:

>>> api.get_forces()
[<Force> Avon and Somerset Constabulary, ..., <Force> Wiltshire Police]
>>> leicestershire = api.get_force('leicestershire')
>>> city_centre = api.get_neighbourhood(leicestershire, 'city-centre-neighbourhood')
>>> city_centre.description
The Castle neighbourhood is a diverse covering all of the City Centre. In addition it covers De Montfort University, the Univesity of Leicester, Leicester Royal Infirmary, the Leicester Tigers rugby ground and the Clarendon Park and Riverside communities.
...
>>> city_centre.contact_details
{u'email': u'central.lpu@leicestershire.pnn.police.uk', u'telephone': u'101', u'address': u'74 Belgrave Gate\n, Leicester, LE1 3GG'}

定位邻居:

>>> n = api.locate_neighbourhood(52.63473, -1.137514)
>>> n
<Neighbourhood> C04
>>> n.force
<Force> Leicestershire Police

犯罪和结果数据:

>>> api.get_latest_date()
u'2013-09'
>>> api.get_crimes_area(city_centre.boundary)
[<Crime> 26926242, ..., <Crime> 26925710]
>>> len(api.get_crimes_area(city_centre.boundary, date='2013-08'))
810
>>> crime = api.get_crimes_area(city_centre.boundary, date='2013-06')[0]
>>> crime.outcomes
[<Crime.Outcome> Under investigation, <Crime.Outcome> Suspect charged, <Crime.Outcome> Awaiting court outcome]

有关更高级的用法,请参见documentation

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

推荐PyPI第三方库


热门话题
javajavax。艾尔。PropertyNotFoundException:   java为什么通过TCP发送的文件比它本身包含的文件包含更多的数据?   java为什么字符开关/案例不起作用?   php到java连接器,在哪里可以找到好的连接器   需要帮助Java简单规则形状面积计算器和if语句吗   macos如何从newstyle Oracle Java OSX捆绑包结构启动帮助页?   java既然所有的类都扩展对象,而对象是一个类,那么对象如何扩展对象呢?   java从JavaPairdd<String,Tuple2<Integer,Integer>>转换为JavaPairdd<String,Integer>   java微调器值未从一个活动传递到另一个活动   参数化类型的java数组   java不提供类。getCanonicalName是否存在性能问题?   java输入键JTextField   为什么我不能在java中调用nextLine()方法两次?   JTextPane中的java JProgressBar   java如何获取Crudepository实例?   用于提取几个<div>标记的java正则表达式   java如何使用JUnit Testrunner生成html图像   Go中Java静态属性的等价性