我最近安装了Twilio模块,我使用的是Python 2.7
Credentials.py - >
account_sid = "AXXXXXXXXXXXXXXXXXXXXXXXXXXXXx"
auth_token = "978XXXXXXXXXXXXXXXXXXXXXX"
my_phone = "+XXXXXXXXXXXX"
my_twilio = "+XXXXXXXXXXXX"
message.py ----->
from twilio.rest import TwilioRestClient
from credentials import account_sid, auth_token, my_phone, my_twilio
client = TwilioRestClient(account_sid, auth_token)
message = 'Hello Sarthak, How are you?'
final_message = client.messages.create(to=my_phone, from_=my_twilio,
body=message)
当我尝试运行此操作时,我收到此错误: -
答案 0 :(得分:2)
From twilio.rest import Client
不推荐使用TwilioRestClient。您必须改为导入客户端。确保你也使用Python 3。