python发短信

安装模块  pip  install  twilio

申请 twilio 手机号 https://www.twilio.com/

代码:

from twilio.rest import Client

account_sid = 'AC07ac0b784cd5a9868be3a51a62bf1d28'
auth_token = '4b24c5a1a6bcaf29abfac08d6ede951a'
client = Client(account_sid, auth_token)

message = client.messages.create(
                    to='+86····',   #你想发的手机号
                    from_='·····',   #你的twilio
                    body="试试发送短信"    #短信内容
                 )

print(message.sid)

看看手机,(刚开始用的时候并没有收到信息,我以为不能用呢。过了几天,心血来潮又运行一次,收到了!)

 

posted @ 2022-06-08 13:55  木_糖  阅读(78)  评论(0编辑  收藏  举报