octopuszy

用刚学的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)

  

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-19
  • 2022-12-23
  • 2021-06-23
  • 2021-11-23
  • 2022-02-13
猜你喜欢
  • 2022-12-23
  • 2021-11-01
  • 2022-12-23
  • 2021-06-10
  • 2021-05-04
  • 2022-12-23
相关资源
相似解决方案