添加行政地区编码
Posted birdmmxx
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了添加行政地区编码相关的知识,希望对你有一定的参考价值。
通过昨天的所在地区省市县的具体化,再这个基础上实现行政地区编码很简单了
if panduan == "1": a = contest[‘geocodes‘][0][‘province‘] b = contest[‘geocodes‘][0][‘city‘] c = contest[‘geocodes‘][0][‘district‘] d = contest[‘geocodes‘][0][‘adcode‘] a = ‘‘.join(a) print(a) with open(‘jeiguo.txt‘, ‘a+‘, encoding="utf-8") as q: q.write(" " + a) b = ‘‘.join(b) print(b) with open(‘jeiguo.txt‘, ‘a+‘, encoding="utf-8") as q: q.write(b) c = ‘‘.join(c) print(c) with open(‘jeiguo.txt‘, ‘a+‘, encoding="utf-8") as q: q.write(c) d = ‘‘.join(d) print(d) with open(‘jeiguo.txt‘, ‘a+‘, encoding="utf-8") as q: q.write("," + d) else: with open(‘jeiguo.txt‘, ‘a+‘, encoding="utf-8") as q: q.write(" " + "查询失败")
以上是关于添加行政地区编码的主要内容,如果未能解决你的问题,请参考以下文章