1. 程式人生 > >Python手機號碼歸屬地查詢

Python手機號碼歸屬地查詢

pip install phone #安裝phone包


import phone


phone.Phone().find('00000000000')


{'area_code': '0531',
 'city': '濟南',
 'phone': '00000000000',
 'phone_type': '聯通',
 'province': '山東',
 'zip_code': '250000'}


import phone
def city(x):
    s='未知'
    try:
        s=phone.Phone().find(x)['city']
    except:
        pass
    return s
df1['城市']=df1.consignee_phone.map(city)