## 判断依据

• 使用2019年5月24日，第一财经新一线城市研究所提出的中国城市新分级名单作为城市分级依据。
• 如果回答者的IP地址来自于克孜勒苏，那么对其跳过判断过程，不进入下一步骤。
• 如果IP地址能明确表明回答者来自于某层级城市，那么将其划入该层级城市。
• 对于未能明确IP所在位置的回答者和IP地址来自克孜勒苏的回答者进行手动判断处理。

## 实现代码

import csv

def get_city_name(file_name):
data=[]
for line in open(file_name,'r'):
data.append(line)
return data

city_1=get_city_name('city1.txt')
city_11=get_city_name('city11.txt')
city_2=get_city_name('city2.txt')
city_3=get_city_name('city3.txt')
city_4=get_city_name('city4.txt')
city_5=get_city_name('city5.txt')

str_ip=[]
str_gk=[]

with open('311.csv',encoding='utf-8') as f:
flag=False
for row in f_csv:
if flag==False:
str1=str(row[5])
str2=str(row[13])
print(row[5])
print(row[13])
flag=True
else:
str_ip.append(row[5])
str_gk.append(row[13])

str_ip_mod=[]
#IP Information Format: 120.229.70.203(广东-深圳)
for i in str_ip:
i=i.split('-')[1][:-1]
str_ip_mod.append(i)

print(str_ip_mod)

res=[9 for i in range(len(str_ip_mod))]
for i in range(len(str_ip_mod)):
if str_ip_mod[i] != '克孜勒苏':
for j in city_1:
if str_ip_mod[i] in j:
res[i]=0
for j in city_11:
if str_ip_mod[i] in j:
res[i]=1
for j in city_2:
if str_ip_mod[i] in j:
res[i]=2
for j in city_3:
if str_ip_mod[i] in j:
res[i]=3
for j in city_4:
if str_ip_mod[i] in j:
res[i]=4
for j in city_5:
if str_ip_mod[i] in j:
res[i]=5

print(res)

need_to_judge=[]
for i in range(10):
count=0
for j in range(len(res)):
if i==res[j]:
count=count+1
if i==9:
if res[j]==9:
need_to_judge.append(j)
print(count)

print(need_to_judge)

for i in need_to_judge:
print(str(i)+":",str_ip[i],str_gk[i])