小编sb2*_*894的帖子

硒和异步

进行这项工作的最佳方法是什么?由于Selenium无法与asyncio配合使用,因此该机器人最终将死亡。它可以按预期工作,但最终会崩溃。我确实知道问题出在哪里,尤其是硒很重,但是有没有好的解决方法?

我收到错误消息:任务已被破坏,但未决!

我没有别的,没有回溯。我必须重新启动机器人(discord),它会再次正常工作。

@bot.command(pass_context=True)
async def weather(ctx, arg):
    if ctx:
        list = ('lf','oahu')
        await bot.say('*Loading webdriver.....*')
        if arg in list:
            if arg == 'lf':
                website = '--'
                name = 'Los Feliz Map'
            if arg == 'oahu':
                website = '--'
                name = 'Oahu Map'
            load_site = webdriver.Chrome()
            # load site on chrome
            load_site.get(website)
            await bot.say('*Loading ' + str(name) + '...*')
            load_site.find_element_by_xpath('//*[@id="main-map"]/div[2]/div[1]/div/a[2]').click()
            load_site.find_element_by_xpath('//*[@id="main-map"]/div[2]/div[2]').click()
            load_site.find_element_by_xpath('//*[@id="main-map"]/div[2]/div[2]/div/form/div[3]/label[6]/div/span').click()
            await asyncio.sleep(2) #sleep to ensure weather loads on site before screenshot
            load_site.save_screenshot('weather.png')
            await bot.say('*Taking screenshot and saving image....*') …
Run Code Online (Sandbox Code Playgroud)

python-3.x selenium-webdriver python-asyncio discord.py

5
推荐指数
0
解决办法
1010
查看次数

Python3 - 3个变量= x的所有可能组合

我试图找到所有可能的组合,其中3个变量可以=某个数字.

x = (10,11,12,13,14,15)
y = (10,11,12,13,14,15)
z = (10,11,12,13,14,15)
answer = 45
Run Code Online (Sandbox Code Playgroud)

我将如何使用itertools找到每个组合

x + y + z = 45
Run Code Online (Sandbox Code Playgroud)

在这种情况下,我希望python打印(15,15,15)但是,如果答案是=不同的数字,如30,它将打印x,y,z的每个组合,当添加时将= 45.

python python-itertools python-3.x

1
推荐指数
2
解决办法
194
查看次数