我正在用Python开发提醒应用程序。我的问题是执行代码时。它应该等到当前日期等于特定日期。但这不起作用,这是我的代码。
代码:
function site_refProfile_existingUser( $meta_id,$user_id) {
remove_action( 'updated_user_meta','site_refProfile_existingUser',10,2);
// your code.....
add_action( 'updated_user_meta',2);
}
此代码无效。 from threading import Thread
from datetime import datetime,timedelta
# Current date,8/15/2020 - 10:00
a = datetime.now()
# Specific date (1 minute later from current date),8/15/2020 - 10:01
b = a + timedelta(minutes = 1)
# Reminder name
d = "stack reminder"
# Reminder list
c = {}
# Target function
def createThread():
while True:
if(b.second == a.second and
b.minute == a.minute and
b.hour == a.hour and
b.day == a.day and
b.month == a.month and
b.year == a.year):
print("worked")
# If thread name in reminder list
if d in c:
print("canceling")
t.cancel()
break
# Set thread and thread name and print thread name
t = Thread(target = createThread)
t.setName(d)
print(t.getName())
# Append reminder name to reminder list and print
c[d] = b
print(c)
# Start thread
t.start()
语句有误吗?我之所以创建if
是因为在程序等待特定日期时,我想做不同的事情。我的错在哪里,如何运行此代码?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。