回覆短信時,我有160個字符的限制。我目前的代碼設置爲回覆(可以是> 160),並將其分成多個文本列表,每個文本列表均爲< 160.它還設置爲使文字保持整體。我把它:拆分SMS回覆
repl='message to be sent. may be >160'
texts=[]
words=repl.split()
curtext=''
for word in words:
#for the first word, drop the space
if len(curtext)==0:
curtext+=word
#check if there's enough space left in the current message
elif len(curtext)<=155-(len(word)+1):
curtext+=' '+word
#not enough space. make a new message
else:
texts.append(curtext)
curtext=word
if curtext!='':
texts.append(curtext)
return texts
不過,我現在想修改它,使它追加「回覆M代表多」,以每秒消息結束。任何想法如何做到這一點?
(我用Python編寫代碼)
你試圖從除非reciever詢問他們發送保留的消息? – 2010-06-18 23:07:11
是的。我不想回復太多的文本 – yydl 2010-06-18 23:08:51
請注意您瞭解如何處理連接的消息,因爲您無法在每個連接部分發送160個字符。所使用的八位字節的確切數量取決於網絡,並且可能會有相當大的變化。它也可能根據您使用哪種服務向網絡提交短信而不同,例如:直接SMPP到網絡,第三方API或到調制解調器的硬件API。 – ptomli 2010-06-19 08:05:00