【问题标题】:How to get Array one by one Randomly in array order in Python如何在Python中按数组顺序随机获取数组
【发布时间】:2021-12-08 05:28:57
【问题描述】:

我已经自动将数字数组中的数字一一发送到文本框,如下所示,而数字是从数组中获取的,同时如何从电子邮件数组?

import time

numbers = [2589001,2589002,2589003,2589004,2589005,2589006,2589007,2589008,2589009,2589010] 
email = ["mail1@gmail.com","mail2@gmail.com","mail3@gmail.com","mail4@gmail.com","mail5@gmail.com"] 

def oo() :
    for idx in email :
    
        email_from_list = email[idx%len(email)]
        
#I want to put those email function code here and need to pass this def oo()

c = 0
def vs () :
    for idx, nm in enumerate(numbers) :
        
        #Number Input
        WebDriverWait(browser, 2500).until(EC.presence_of_element_located((By.NAME, "Number"))).send_keys(nw)
        time.sleep(1)
        
        WebDriverWait(browser, 2500).until(EC.presence_of_element_located((By.NAME, "Number"))).send_keys(oo()) #<---- here need to call
        time.sleep(1)
        #I need code here to get email id one by one randomly from array   <--- Fix you wording. You don't actually want them one by one randomly

w = 0     
while w < 50 :
    vs ()
    w += 1

【问题讨论】:

  • 这个问题不应该被标记为 selenium-chromedriver;它与 Selenium 无关。

标签: python python-3.x selenium-webdriver python-requests selenium-chromedriver


【解决方案1】:

我已阅读您的评论,您所描述的不是您在原始帖子/问题中所要求的。您想要的是遍历相同的电子邮件列表(不想选择随机电子邮件)。

import time

numbers = [2589001,2589002,2589003,2589004,2589005,2589006,2589007,2589008,2589009,2589010] 
email = ["mail1@gmail.com","mail2@gmail.com","mail3@gmail.com","mail4@gmail.com","mail5@gmail.com"] 

c = 0
def vs () :
    for idx, nm in enumerate(numbers) :
        
        #Number Input
        WebDriverWait(browser, 2500).until(EC.presence_of_element_located((By.NAME, "Number"))).send_keys(nw)
        time.sleep(1)
        
        #I need code here to get email id one by one randomly from array   <--- Fix you wording. You don't actually want them one by one randomly
        email_from_list = email[idx%len(email)]
        


w = 0     
while w < 50 :
    vs ()
    w += 1

【讨论】:

  • 一旦我打印(email_from_list)电子邮件没有从数组中获得订单。
  • 没有得到订单是什么意思?
  • 优秀..!这个功能很完美,正如我所需要的,我只需要改变我在主帖中编辑的一点你能支持我吗,我需要def中的那些电子邮件功能,需要将def调用到.send_keys (oo())
  • 如果它符合您的需求,请确保接受该解决方案
  • 它被接受了,你能帮我从 def 获取电子邮件功能并调用 .send_keys(oo())
猜你喜欢
  • 1970-01-01
  • 2012-11-19
  • 1970-01-01
  • 2020-03-03
  • 2012-03-21
  • 2019-03-19
  • 2020-02-16
  • 2021-05-31
  • 1970-01-01
相关资源
最近更新 更多