所以,我试图用Python创建一个脚本来自动打开在线类。 这是我的代码:
import webbrowser
import datetime
import time
now = time.strftime("%D, %H:%M")
lesson1 = "03/09/21, 14:10"
lesson2 = "03/10/21, 14:11"
lesson3 = "03/10/21, 14:12"
while True (now != lesson1 and now != lesson2 and now != lesson3):
print ("Waiting, the current time is " + now)
now = time.strftime("%D, %H:%M")
time.sleep(1)
if (now == lesson1):
print ("LESSON IS OPENING :D")
webbrowser.open("https://google.com")
while (now != "12:00"):
time.sleep()
if (now == lesson2):
print ("LESSON IS OPENING :D")
webbrowser.open("https://google.com")
if (now == lesson3):
print ("LESSON IS OPENING :D")
webbrowser.open("https://google.com")
当我尝试运行脚本时,会收到以下消息:
Traceback (most recent call last):
File "/home/matteo/Desktop/Python Project/automatic.py", line 11, in <module>
while True (now != lesson1 and now != lesson2 and now != lesson3):
TypeError: 'bool' object is not callable
[Finished in 0.053s]
有人能帮我吗
我认为你想要的条件相当好
True (now != lesson1 and now != lesson2 and now != lesson3)
被视为对True
的函数调用,该函数不是可调用的,而是布尔值另外,我认为您可能希望将三个
if
移动到while
循环之后,这样,只有在while
终止时,才会在三个可能的值之间检查时间相关问题 更多 >
编程相关推荐