def value(startH,startM,stopH,stopM):
def job():
do job
def job1():
do another job
start_time = "{0:02d}:{1:02d}".format(startH, startM)
stop_time = "{0:02d}:{1:02d}".format(stopH, stopM)
schedule.every().day.at(start_time).do(job)
schedule.every().day.at(stop_time).do(job1)
while True:
schedule.run_pending()
time.sleep(1)
此处startH,startM,stopH,stopM表示开始时间,开始分钟,停止时间和停止分钟。这是用户通过android给出的输入。此代码运行。它运行onces,然后继续运行。这是恳求。如果我想让用户再次输入时间。它不会接受。在循环仍在运行时,如何接受来自用户的输入?让我们说第一个任务说打开灯,然后第二个任务是关闭灯。所以当第二项任务完成时。它被认为是完整的。我尝试过使用break,return。它不会像预期的那样工作。如何在while循环中运行并仍然接受用户输入?
public void publish(int startH,int startM, int stopH, int stopM)
{
JSONObject js = new JSONObject();
try {
js.put("START_HOUR", startH);
js.put("START_MINUTE", startM);
js.put("STOP_HOUR", stopH);
js.put("STOP_MINUTE", stopM);
}
public void setTime(View view)
{
int storeStartHour = Integer.parseInt(startHrs.getText().toString());
int storeStartMinutes = Integer.parseInt(startMinutes.getText().toString());
int storeStopHour = Integer.parseInt(stopHrs.getText().toString());
int storeStopMinutes = Integer.parseInt(stopMinutes.getText().toString());
publish(storeStartHour, storeStartMinutes, storeStopHour, storeStopMinutes);
}
使用线程,Luke – Sergius
它被称为线程例如。该或异步/非阻塞代码。我看到这里没有用户输入,不知道我会把它放在哪里。 – Torxed
@Toxxed来自android的输入存储在startH中,startH是开始小时,startM是开始分钟,stopH和stopM等等。它可以设置一次。然后我不能再设置... – sam