首页 > 解决方案 > 在 python selenium 脚本上运行多个函数

问题描述

我对编写 python 脚本相当陌生,我想知道如何使不同的def功能同时工作,我有以下代码:

class gameBot:
    def __init__(self, username, password):
        (basically logs into the game with username and password)

def moving_on(self, cronometer, energy, no_energy):
        (checks if energy is able to refill and refills automatically)

bot = gameBot(username, password)
bot.moving_on(cronometer, energy, no_energy)

所以我想了解的是,如果我有多种def功能(假设一个用于补充能量,如上图所示,另一个用于在游戏中发送消息等),我如何让它们同时运行,并且从不-结束循环?谢谢

标签: pythonpython-3.xseleniumselenium-webdriver

解决方案


在同一时间运行你必须使用

python的多处理或线程模块

并使用 while 循环来实现永无止境的循环


推荐阅读