Python 为什么for循环不移动到列表中的第二项
我有一个嵌套循环,它在列表中的第一个项目上正常工作,但随后完成 不确定为什么它不移动第二项Python 为什么for循环不移动到列表中的第二项,python,nested-loops,Python,Nested Loops,我有一个嵌套循环,它在列表中的第一个项目上正常工作,但随后完成 不确定为什么它不移动第二项 serials =['BHT350018400', 'BHTM0016380'] url_latency = 'https://my_company/ui/index.html#' file_system_start_string = '/filesystems/unif/' file_system_end_string = '__FILESYSTEM__fs_' section = 'performan
serials =['BHT350018400', 'BHTM0016380']
url_latency = 'https://my_company/ui/index.html#'
file_system_start_string = '/filesystems/unif/'
file_system_end_string = '__FILESYSTEM__fs_'
section = 'performance'
count = 1
file_system_count = (str(count))
for serial in serials:
for file in serial:
while count < 5:
full_url = url_latency + file_system_start_string + serial + file_system_end_string + file_system_count + '/' + section
driver.get(full_url)
driver.maximize_window()
WebDriverWait(driver, 15).until(EC.element_to_be_clickable((By.XPATH,'//*[@id="shell-plugin-area"]/div/div/div/div[2]/ciq-tab-panel/div/div/div/div[3]/div/div/div/div/div/div/div[2]/ciq-performance-details/div/div[1]')))
screenShot_path = "\screengrab" + file_system_count + ".png"
screenshot = driver.save_screenshot(file_path + screenShot_path)
time.sleep(1)
count += 1
file_system_count = (str(count))
print(full_url)
serials=['BHT350018400','BHTM0016380']
url\uhttps://my_company/ui/index.html#'
文件系统启动字符串='/filesystems/unif/'
文件\u系统\u结束\u字符串='\u文件系统\u文件系统\u
节=‘性能’
计数=1
文件系统计数=(str(计数))
对于串行中的串行:
对于串行文件:
当计数小于5时:
完整url=url延迟+文件系统开始字符串+串行+文件系统结束字符串+文件系统计数+'/'+节
获取驱动程序(完整url)
驱动程序。最大化_窗口()
WebDriverWait(driver,15).until(EC.element可点击((By.XPATH,'/*[@id=“shell plugin area”]/div/div/div/div[2]/ciq选项卡面板/div/div/div/div/div[3]/div/div/div/div/div/div[2]/ciq性能详细信息/div/div/div[1]))
屏幕截图\路径=“\screengrab”+文件\系统\计数+”.png”
屏幕截图=驱动程序。保存屏幕截图(文件路径+屏幕截图路径)
时间。睡眠(1)
计数+=1
文件系统计数=(str(计数))
打印(完整url)
您需要重置“count”变量
比如说:
serials =['BHT350018400', 'BHTM0016380']
url_latency = 'https://my_company/ui/index.html#'
file_system_start_string = '/filesystems/unif/'
file_system_end_string = '__FILESYSTEM__fs_'
section = 'performance'
count = 1
file_system_count = (str(count))
for serial in serials:
for file in serial:
count=1 # <------------ here
while count < 5:
full_url = url_latency + file_system_start_string + serial + file_system_end_string + file_system_count + '/' + section
driver.get(full_url)
driver.maximize_window()
WebDriverWait(driver, 15).until(EC.element_to_be_clickable((By.XPATH,'//*[@id="shell-plugin-area"]/div/div/div/div[2]/ciq-tab-panel/div/div/div/div[3]/div/div/div/div/div/div/div[2]/ciq-performance-details/div/div[1]')))
screenShot_path = "\screengrab" + file_system_count + ".png"
screenshot = driver.save_screenshot(file_path + screenShot_path)
time.sleep(1)
count += 1
file_system_count = (str(count))
print(full_url)
serials=['BHT350018400','BHTM0016380']
url\uhttps://my_company/ui/index.html#'
文件系统启动字符串='/filesystems/unif/'
文件\u系统\u结束\u字符串='\u文件系统\u文件系统\u
节=‘性能’
计数=1
文件系统计数=(str(计数))
对于串行中的串行:
对于串行文件:
count=1#您的内部循环正在通过每个字符串B、H、T等中的字符循环。这是预期的行为吗?嵌套循环应该遍历什么?而且你不重置count
,这就是为什么它第二次不会做任何事情的原因感谢你给我指明了正确的方向,我没有打算遍历每个字符,循环是在构建URL,实际上我不需要内部循环,它现在可以正常工作了