1.单线程实例: 代码如下: from time import ctime,sleep def music(A): for i in range(2): print ("I was listening to %s. %s" % (A, ctime())) sleep(1) def eat(B): for i in range(2): print ("I was eating the %s! %s" % (B, ctime())) sleep(5) if __name
L = ['you','me','you','me','you','me','you'] D = {} for i in L: D[i] += 1 print(D) 执行以下代码会发生错误 Traceback (most recent call last): File line 4, in <module> D[i] += 1 KeyError: 'you' Process finished with exit code 1 为什么呢?因为我们在定义字典的时候没设置默认值,电脑找不到相应对象,
显式等待 显式等待使 WebdDriver 等待某个条件成立时继续执行,否则在达到最大时长时抛弃超时异常 (TimeoutException). #coding=utf-8 from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support