如何使用python gsmmodem模块发送unicode字符?

时间:2019-01-18 04:11:06

标签: python unicode sms gsm

我正在尝试使用python-gsmmodem-new v0.12模块发送unicode字符。 https://www.pydoc.io/pypi/python-gsmmodem-new-0.12/autoapi/modem/index.html 当我发送GSM-7消息时,它可以正常工作。

但是,当我尝试发送unicode消息时,它会显示"Unable to set SMS encoding (enocoding UCS2 not supported)"

try:
    modem.sendSms('3473438473', '测试')
except TimeoutException:
    sys.stderr.write('Time out.\n')
except CommandError:
    sys.stderr.write('Failed.\n')

以下是结果:

Traceback (most recent call last):

File "/Users/user/Sites/mobilesmsPython/mobileSMS.py", line 651, in <module>
main()

File "/Users/user/Sites/mobilesmsPython/mobileSMS.py", line 389, in main
modem.sendSms('3473438473', '测试')

File "/Users/user/Sites/mobilesmsPython/gsmmodem/modem.py", line 919, in sendSms
self.smsEncoding = 'UCS2'

File "/Users/user/Sites/mobilesmsPython/gsmmodem/modem.py", line 712, in smsEncoding
raise ValueError('Unable to set SMS encoding (enocoding {0} not supported)'.format(encoding))

ValueError: Unable to set SMS encoding (enocoding UCS2 not supported)

0 个答案:

没有答案