用刚学的eval()方法对代码进行了改进,感觉发现了新大陆
#!/usr/local/bin/python3
# -*- coding:utf-8 -*-
count=0
with open("location_data3",\'w\',encoding="utf-8") as f:
for a in open("location_data",\'r\',encoding="utf-8").read():
if a!=\'(\' and a!=\')\':
f.write(a)
elif a==\'(\':
f.write(\'[\')
elif a==\')\':
f.write(\']\')
for i in eval(open("location_data3",\'r\',encoding="utf-8").readline()):
if i[0]<500 and i[1]<1000: #这里调参数
count+=1
print(i)
print(count)