python送给父亲的代码
时间: 2023-07-10 18:03:25 浏览: 49
以下是一个简单的Python代码,可以向父亲发送一条问候短信:
```python
import requests
def send_sms(message):
url "https://sms-api.luosimao.com/v1/send.json"
api_key = "YOUR_API_KEY" # 替换为你自己的 API Key
payload = {
"mobile": "父亲的手机号", # 替换为父亲的手机号
"message": message
}
headers = {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Basic " + api_key
}
response = requests.post(url, data=payload, headers=headers)
if response.status_code == 200:
print("发送成功!")
else:
print("发送失败:", response.text)
# 替换为你自己想要发送的问候语
message = "亲爱的父亲,祝您健康、快乐、平安!"
send_sms(message)
```
注意,这个代码需要使用短信服务商的 API Key 和父亲的手机号码,才能将短信发送出去。在实际使用时,请替换这些参数为你自己的信息。