【发布时间】:2020-09-06 10:14:27
【问题描述】:
TOKEN = 'token'
bot = telebot.TeleBot(TOKEN)
def main():
for i in range(0,100):
print(i)
@bot.message_handler(commands=['start'])
def start(message):
main()
@bot.message_handler(commands=['stop'])
def stopfunc(message):
#how to stop the function main() ?
while True:
bot.polling()
【问题讨论】:
-
实现这一点的一种方法是线程化,但我不能建议这样做,因为我不知道你究竟需要实现什么。但是为什么不在主函数中使用“if-else”语句呢?你有什么理由不能?
标签: python function telegram-api