首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >python中带参数的函数指针?

python中带参数的函数指针?
EN

Stack Overflow用户
提问于 2012-05-27 09:38:56
回答 1查看 597关注 0票数 0

我正在读取pythons Cron-job中的文档(示例1):

代码语言:javascript
运行
复制
from apscheduler.scheduler import Scheduler

# Start the scheduler
sched = Scheduler()
sched.start()

def job_function():
    print "Hello World"

# Schedules job_function to be run on the third Friday
# of June, July, August, November and December at 00:00, 01:00, 02:00 and 03:00
sched.add_cron_job(job_function, month='6-8,11-12', day='3rd fri', hour='0-3') 

是否可以将参数添加到job_function以及如何将它们传递给add_cron_job

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-05-27 09:43:48

使用args关键字参数:

代码语言:javascript
运行
复制
# call job_function with arguments 'hello' and 'world'
sched.add_cron_job(job_function, args=('hello', 'world'), month='1', day='1st fri', hour='0') 

参见the definition of add_cron_job

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10771052

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档