python - 在 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
功能(假设一个用于补充能量,如上图所示,另一个用于在游戏中发送消息等),我如何让它们同时运行,并且从不-结束循环?谢谢
解决方案
在同一时间运行你必须使用
python的多处理或线程模块
并使用 while 循环来实现永无止境的循环
推荐阅读
- c# - 是否可以投射 Func
- python-3.x - Kafka 消息在消费者中拆分
- azure-active-directory - DUO 是否与 Microsoft Azure Active Directory B2C 集成?
- node.js - 如何将 git prehook 添加到 tslint?
- node.js - 在 Windows Server 上使用 PM2 无法访问节点服务器
- python - Python实时绘图,重新更新
- sql - 从不同的列加入同一张表上的多个计数?
- java - 多线程应用Java中的PrioirtyBlockingQueue
- javascript - 如何仅将参数传递给需要它的中间件?
- excel - 如何在 Excel 单元格中查找相同字符的第二次出现