复杂循环与python和selenium变量

时间:2018-02-17 15:38:26

标签: python selenium

我为我的项目循环而斗争: 例如:

user = "1" , "2", ...

Link = www.test.com/

我能做什么呢?

www.test.com/1
does something

www.test.com/2
does the same thing

...

所以它为每个用户做同样的事情

1 个答案:

答案 0 :(得分:2)

您可以创建一个功能并将其应用于用户列表:

def perform_for_each_user(user_list, link):
    for user in user_list:
        user_link = link + user
        print(user_link)
        # do something with user_link

users = "1" , "2", "3"

perform_for_each_user(users, "www.test.com/")