[Python] 纯文本查看 复制代码import cloudmusic
import os, time, smtplib, socket, sys
def comparedict(ca,cb):
c=[]
for ci in cb:
if ca[ci]!=cb[ci]:
c.append(ci)
return(c)
a=cloudmusic.getUser(111111111)
b=cloudmusic.getUser(222222222)
c=cloudmusic.getUser(333333333)
[email protected]
mid=[a,b,c]
countmap0={}
for i in mid:
countmap0[i.nickname]=i.eventCount
time.sleep(5)
print(countmap0)
countmap={}
for timestep in range(10):
for i in mid:
countmap[i.nickname]=i.eventCount
time.sleep(1)
a=cloudmusic.getUser(111111111)
b=cloudmusic.getUser(222222222)
c=cloudmusic.getUser(333333333)
mid=[a,b,c]
print('timestep=%d %s'%(timestep,countmap))
if timestep==0:
os.system('echo "This email is from 52pojie, have fun!" | mail -s "Now starts cm(py)." %s'%your_email_address)
elif timestep==28800000000:
os.system('echo "This email is from 52pojie, have fun!" | mail -s "Program cm(py) ended." %s'%your_email_address)
elif timestep%720==0:
print('timestep=%d %s'%(timestep,countmap))
else:
if comparedict(countmap0,countmap)!=[]:
updater=comparedict(countmap0,countmap)[0]
os.system('echo "This email is from 52pojie, have fun!" | mail -s "%supdated!" %s'%(updater,your_email_address))
sentence='%s'%updater+' updated dynamics.'
print(sentence)
for i in mid:
countmap0[i.nickname]=i.eventCount
time.sleep(1)
time.sleep(10)