• Python面向对象


    Python面向对象

    #coding:utf-8
    #获取地址信息
    import sys,requests,md5
    
    
    #通过高德地图api获取地址信息
    def get_geocodeG(address):
        result = {}
        par = {'address': address, 'key': 'cb649a25c1f81c1451adbeca73623251'}
        base = 'http://restapi.amap.com/v3/geocode/geo'
        response = requests.get(base, par)
        answer = response.json()
        result['address'] = address
        try:
            result['province'] = answer['geocodes'][0]['province']
            result['city'] = answer['geocodes'][0]['city']
            result['citycode'] = answer['geocodes'][0]['citycode']
            result['district'] = answer['geocodes'][0]['district']
            result['level'] = answer['geocodes'][0]['level']
            result['adcode'] = answer['geocodes'][0]['adcode']
            result['locationX'] = answer['geocodes'][0]['location'].split(',')[0]
            result['locationY'] = answer['geocodes'][0]['location'].split(',')[1]
            result['formatted_address'] = answer['geocodes'][0]['formatted_address']
        except:
            pass 
        return result 
        
    #address = "台州市椒江区开元小区内"
    #result = get_geocodeG(address)
    #print result['district'],result['formatted_address'],result['locationX'],result['locationY']
    
    #定义学校基础类
    class School(object):
        '''学校基础类'''
        def __init__(self,id='',name='',type='',address='',postCode='',areaCode='',tel=''):
            self.id = id
            self.name = name
            self.type = type
            self.address = address
            self.postCode = postCode
            self.areaCode = areaCode
            self.tel = tel
        def __str__(self):
            return 'id:%s,name:%s,type:%s,'%(self.id,self.name,self.type)
            
    class Collage(School):
        def __init__(self,id='',name='',type='',address='',locationX='',locationY='',postCode='',areaCode='',tel='',fax='',url=''):
            super(Collage,self).__init__(id,name,type,address,postCode,areaCode,tel)
            self.locationX = locationX
            self.locationY = locationY
            self.fax = fax
            self.url = url
        
        def __str__(self):
            return 'id:%s,name:%s,type:%s,url:%s'%(self.id,self.name,self.type,self.url)
            
    #1133000002    仙居县中心幼儿园    城关南门街186号    317300    0576    89386288
    school = School('1133000002','仙居县中心幼儿园','幼儿园','城关南门街186号','317300','0576','89386288')
    
    print school.name
    print school
    
    #4133010335    浙江大学    高等学校    杭州市西湖区余杭塘路866号    120.0213889    30.22083333    310058    0571    88981583    88981358    www.zju.edu.cn
    collage = Collage('4133010335','浙江大学','高等学校','杭州市西湖区余杭塘路866号','120.0213889','30.22083333','310058','0571','88981583','88981583','www.zju.edu.cn')
    print collage
     
    '''
    print School.__name__
    print School.__doc__
    print School.__bases__
    print School.__dict__
    print School.__module__
    
    '''
  • 相关阅读:
    安装64位Oracle 10g超详细教程
    Linux同平台Oracle数据库整体物理迁移
    Oracle 删除重复数据只留一条
    linux下通过脚本实现自动重启程序的方法
    Linux查看系统开机时间
    Linux下oracle数据库启动和关闭操作
    curl: (6) Couldn’t resolve host ‘www.ttlsa.com’
    linux 怎么查找oracle11g的安装目录
    Linux系统管理员:不要害怕升级内核
    The Binder Architecture
  • 原文地址:https://www.cnblogs.com/Jims2016/p/8433336.html
Copyright © 2020-2023  润新知