指导一下怎么输出中文,谢谢
CNMan opened this issue · 2 comments
CNMan commented
照猫画虎弄了个phonecheck.py在win命令行用,不知道怎么输出中文,请指导一下,谢谢
import argparse
from phone import Phone
parser = argparse.ArgumentParser()
parser.add_argument("PhoneNumber")
args = parser.parse_args()
p = Phone()
print p.find(args.PhoneNumber)
E:\dev\python-2.7.10.amd64\python.exe phonecheck.py 1888888
{'province': '\xe5\x8c\x97\xe4\xba\xac', 'phone_type': '\xe7\xa7\xbb\xe5\x8a\xa8', 'city': '\xe5\x8c\x97\xe4\xba\xac', 'area_code': '010', 'phone': '1888888', 'zip_code': '100000'}
CNMan commented
Google帮我搞定了,多谢:)
1389341 应该显示"兰州市红古区",现在只显示"红古区"
# -*- coding: utf-8 -*-
import argparse
from phone import Phone
parser = argparse.ArgumentParser()
parser.add_argument("PhoneNumber")
args = parser.parse_args()
p = Phone()
data = p.find(args.PhoneNumber)
print u'\u624b\u673a\u53f7' + ': ' + unicode(data['phone'],'utf-8')
print u'\u7701\u3000\u4efd' + ': ' + unicode(data['province'],'utf-8')
print u'\u5e02\u53bf\u533a' + ': ' + unicode(data['city'],'utf-8')
print u'\u8fd0\u8425\u5546' + ': ' + unicode(data['phone_type'],'utf-8')
print u'\u533a\u3000\u53f7' + ': ' + unicode(data['area_code'],'utf-8')
print u'\u90ae\u3000\u7f16' + ': ' + unicode(data['zip_code'],'utf-8')
ls0f commented
感谢反馈,我有时间再整理下数据。