[Python] 纯文本查看 复制代码 def main():
room_info = {"大司马":606118, "余小C":1126960, "骚猪":101, "周淑怡":290935}
for key in room_info.keys():
live_addr = liveAddr(room_info[key])
if live_addr == None:
room_info[key] = "未开播"
else:
room_info[key] = live_addr
get_txt = readTxt(room_info)
if get_txt[0] == 1:
live_info = get_txt[1].split('\n')
ret = '\n'.join(live_info)
SendMail(ret).mail()
else:
ret = []
live_info = get_txt[1].split('\n')
for i in range(len(live_info)):
for key,value in room_info.items():
if key in live_info[i] and value in live_info[i]:
break
elif key in live_info[i] and value not in live_info[i]:
if value == "未开播":
pass
else:
ret.append('{}:{}'.format(key,value))
live_info[i] = '{}:{}'.format(key,value)
break
with open('liveinfo.txt','w+') as f:
f.write('\n'.join(live_info))
f.close()
if len(ret) != 0:
SendMail('\n'.join(ret)).mail()
|