我有以下代码,但它似乎在调试print语句之前卡在Text函数中。我觉得它与我的函数参数如何设置变量有关,但我不确定这样做的正确方法是什么。
from twilio.rest import TwilioRestClient
Initialize(debug=False):
global Twilio
Twilio = TwilioRestClient('***', '***')
global Numbers
Numbers = {'***':'+***', '***':'+***', '***':'+***'}
if debug:
print 'Intialize Debug Enabled'
def Text(message, recipient, debug=False):
Twilio.messages.create(body=message, to=recipient, from_='+***')
if debug:
print 'Text Debug Enabled'
while True:
Initialize(True)
Text('***', Numbers['***'], True)
答案 0 :(得分:0)
试试这个:
from twilio.rest import TwilioRestClient
client = None
Numbers = None
def Initialize(debug=False):
global client
client = TwilioRestClient('***', '***')
global Numbers
Numbers = {'***':'+***', '***':'+***', '***':'+***'}
if debug:
print 'Intialize Debug Enabled'
def Text(message, recipient, debug=False):
client.messages.create(body=message, to=recipient, from_='+***')
if debug:
print 'Text Debug Enabled'
Initialize(True)
for k, v in Numbers.items():
Text(k, v, True)