get
method detected PTC-W0031push_config.get('PUSH_KEY')
337 print("serverJ 服务启动")
338
339 data = {"text": title, "desp": content.replace("\n", "\n\n")}
340 if push_config.get("PUSH_KEY").index("SCT") != -1:341 url = f'https://sctapi.ftqq.com/{push_config.get("PUSH_KEY")}.send'
342 else:
343 url = f'https://sc.ftqq.com/${push_config.get("PUSH_KEY")}.send'
push_config.get('DD_BOT_SECRET')
157 print("钉钉机器人 服务启动")
158
159 timestamp = str(round(time.time() * 1000))
160 secret_enc = push_config.get("DD_BOT_SECRET").encode("utf-8")161 string_to_sign = f'{timestamp}\n{push_config.get("DD_BOT_SECRET")}'
162 string_to_sign_enc = string_to_sign.encode("utf-8")
163 hmac_code = hmac.new(
push_config.get('BARK_PUSH')
97
98 if push_config.get("BARK_PUSH").startswith("http"):
99 url = (
100 f'{push_config.get("BARK_PUSH").rstrip("/")}/'101 f"{urllib.parse.quote_plus(title)}/{urllib.parse.quote_plus(content)}"
102 )
103 else:
push_config.get('BARK_PUSH')
95 return
96 print("bark 服务启动")
97
98 if push_config.get("BARK_PUSH").startswith("http"): 99 url = (
100 f'{push_config.get("BARK_PUSH").rstrip("/")}/'
101 f"{urllib.parse.quote_plus(title)}/{urllib.parse.quote_plus(content)}"
push_config.get('BARK_PUSH')
126
127 if push_config.get("BARK_PUSH").startswith("http"):
128 url = (
129 f'{push_config.get("BARK_PUSH").rstrip("/")}/'130 f"{urllib.parse.quote_plus(title)}/{urllib.parse.quote_plus(content)}"
131 )
132 else:
Use of a method on the return value of a dictionary's get
method without checking if the value exists may give an AttributeError
during runtime.
By default, the get
method returns None
if the key is not found in the dictionary.
It is recommended to either provide a default
value to be returned by get
when key doesn't exist, or check that the default value is not None
before using any other method on it.
def generate_username(name):
return student_record.get(name).lower()
def generate_username(name):
official_name = student_record.get(name)
return official_name.lower() if official_name else None