如何使用以下代码制作脚本python



晚上好,

我有一个关于这个python代码的问题。

import requests
resp = requests.post('https://textbelt.com/text', {
'phone': '5555555555',
'message': 'Hello world',
'key': 'textbelt',
})
print(resp.json())

我有一个有100个电话号码的列表,我想用一个脚本一个接一个地给他们发短信。

也许有一种更聪明/更好的方法来制作代码,我真的不知道。如何更改"电话":"……"它一个接一个地获取数字并执行它。那么,与其复制每个数字,有没有一种方法可以让它自动执行呢?

感谢您抽出时间!!

问候,

土耳其

您应该将您的电话号码存储在列表中,然后对其进行迭代。

import requests
phone_numbers = [5555555555,6666666666] # all of your phone numbers here
for phone_number in phone_numbers: # for every number, send the sms
resp = requests.post('https://textbelt.com/text', { 'phone': phone_number, 'message': 'Hello world', 'key': 'textbelt'}) 

最新更新