代码如下,请问为什么这个代码的icot会报错呢,自学的python,没经过特殊的学习,不知道为什么这个会报错
from threading import Timer
from selenium import webdriver
import os, csv
def __init__():
global data
data = []
def open_up():
global icot
icot = 0
global driver
driver = webdriver.Edge(executable_path=r'D:\anaconda\envs\yolo\msedgedriver.exe')
driver.get("https://lbs.amap.com/tools/creater") # https://www.douban.com/
def hello():
if data == [] and icot == 0:
os.remove('FlyPoints.csv')
f = open('FlyPoints.csv', 'w', encoding='utf-8', newline='')
try:
longitude = driver.find_element("xpath",
'//*[@class="overlay_item marker current"]/div[2]/div[2]/div[2]/div/span[1]').text
latitude = driver.find_element("xpath",
'//*[@class="overlay_item marker current"]/div[2]/div[2]/div[2]/div/span[2]').text
if data[icot] != (longitude, latitude) and latitude != '' and longitude != '':
print(longitude)
print(latitude)
data.append((longitude, latitude))
icot = icot + 1
except:
pass
if icot >= 10:
csv_write = csv.writer(f)
csv_write.writerows(data)
return
Timer(1.0, hello).start()
def close_down():
driver.close()