我要求用户输入min_number和max_number。例如,用户设置min_number:2和max_number:6
随机给我[3,5]和这个错误
random=random.sample(范围(1,80(,min_number(AttributeError:"list"对象没有属性"sample">
"列表"对象没有属性"sample">
while min_number <= max_number:
random = random.sample(range(1, 10), min_number)
print (random)
for j in random:
element = wait.until(EC.element_to_be_clickable((By.XPATH, f'//*[@id="app"]/div/div[3]/div/div[1]/div[{j}]/div')))
element.click()
time.sleep(1)
j += j
min_number += min_number
这是因为random是lib的名称。
尝试在arandom =
中重命名random =
,例如
下面的代码不再有错误:
import random
while 2 <= 3:
arandom = random.sample(range(1, 10), k=1)
print (arandom)
for j in arandom:
j += j