有没有一种方法可以使用python中的schedule模块请求输入?

时间:2020-10-24 16:15:48

标签: python

我是python的新用户,实际上我只是想尝试一下该语言。目前,我正在尝试构建一个Python脚本,该脚本将使用schedule模块在特定时间打开所有类链接。我希望能够询问用户何时要打开该链接,但是我不确定如何获取输入并使用用户当时在计算机上提供的内容来打开该URL。我可以打开该URL,但无法在特定时间打开它。有人知道这是否可能吗? 我已在下面附加了代码,并用粗体显示了特定的块

import webbrowser
import schedule

import time

url = input("Enter your url: ")

day1 = input("Enter the day: ")

time = input("Enter the time: ")

do = input("Do you want to start at " + day1 +  time)

def open():

    webbrowser.open_new_tab(url)

schedule.every().day1.at('time').do(open)

1 个答案:

答案 0 :(得分:0)

由于计划包不提供使用>天周期规则来计划作业的界面。您应该将这样的事情作为安排在特定日期进行的修改。

import webbrowser
import schedule

import time

from datetime import date

url = input("Enter your url: ")

# accept month & day as numbers
month = int(input("Enter the month (1-12): "))
day = int(input("Enter the day (1-31):"))

time = input("Enter the time: ")

def open():
    today = date.today()
    if today.month == month and today.day == day:
        # do your work here
        webbrowser.open_new_tab(url)

schedule.every().day.at(time).do(open)