如何返回Gammu Python SendSMS函数发送状态?

2024-06-16 11:03:25 发布

您现在位置:Python中文网/ 问答频道 /正文

嗨,谢谢你抽出时间来帮忙。在

我正在使用以下代码

#!/usr/bin/env python
# Sample script to show how to send SMS

import gammu
import sys


sm = gammu.StateMachine()
sm.ReadConfig()
sm.Init()

message = {
    'Text': 'python-gammu testing message',
    'SMSC': {'Location': 1},
    'Number': '+584126555508',
}

# Actually send the message
sm.SendSMS(message)

它工作得很好,但是我怎样才能确保SendSMS函数真的发送了消息。。。在

例如:send,unsent作为SendSMS函数返回值的结果。在

感谢您提前回答。在


Tags: tosample函数代码importenvsendmessage
1条回答
网友
1楼 · 发布于 2024-06-16 11:03:25
try:
  # Send SMS if all is OK
  sm.SendSMS(message)
  print 'Success, SMS was Sent'

except gammu.GSMError:
    # Show error if message not sent
    print 'Error, SMS not Sent'

相关问题 更多 >