标签:pip number 实现 == cli windows http 时间 range
pip install qcloudsms_py
from qcloudsms_py import SmsSingleSender from qcloudsms_py.httpclient import HTTPError from settings import constant # 在文件中配置常量 from .logging import logger # 记录日志 # mac要加入以下两句代码,windows可加可不加 import ssl ssl._create_unverified_context = ssl._create_default_https_context _app_id = constant.APP_ID # 在腾讯云中申请自己的appid _app_key = constant.APP_KEY # 在腾讯云中申请自己的app_key _template_id = 402722 # 模板id _sms_sign = "**的技术栈" # 短信签名内容 # 需要发送短信的手机号码 phone_numbers = ["1851657****"] _sender = SmsSingleSender(_app_id, _app_key) import random def get_code(): code = ‘‘ for i in range(4): code += str(random.randint(0, 9)) return code def send_sms_params(mobile, code, ex): # code:验证码 ex:过期时间 result = None try: result = _sender.send_with_param(86, mobile, _template_id, (code, ex), sign=_sms_sign, extend="", ext="") except HTTPError as e: logger.warning(e) except Exception as e: logger.warning(e) if result and result.get(‘result‘) == 0: return True return False
标签:pip number 实现 == cli windows http 时间 range
原文地址:https://www.cnblogs.com/zhouze/p/11431618.html