初入职场,被人使唤来使唤去是一种常态,这不,又来事了。
领导bia滴扔给我一沓表格,让我把上个月没交会费的大咖找出来,挨个儿发催缴信。
哦,忘记介绍了,我在大咖党党支部工作,负责端茶、倒水、查资料、收快递类杂事。
我定睛一看,艾玛,这么多表格,密密麻麻滴呀!再仔细点,发现表格是打印出来的,赶紧问电子版在哪里?领导手一指让我寄几去电脑里找。
只要是excel文件登记就好办。
把前几天那个对excel文件操作的python代码和发送邮件的代码翻出来,两个拼吧拼吧改吧改吧...很快就弄出一个从excel文件中提取出欠费的名字和对应的电子邮件,然后一一发送邮件的程序。
这样不仅是把今天老板交代的任务完成了,也把以后老板交代的类似任务完成了。今个儿老百姓是真呀真高兴!
人工智能时代都快来了,谁还苦哈哈滴趴表格上自己找啊?!
兴冲冲滴跑去跟领导邀功,没想到被骂了回来,领导说我没长脑袋,就没考虑到大佬们不看电子邮箱怎么办么?!
回到座位上抱着脑袋想了半天,大咖不看电子邮箱,但不能不看手机吧,我何不在发送电邮的同时,再加上短信泥?
python发送短信也很简单,因为现在很多支持python的短信发送服务的提供商,我只要把技术要求把参数填好,然后把代码贴到自己的程序上就行啦
......
就这样我有了电子邮件和短信双重加码的催款通知:
题目:拖欠的人是可耻的!
正文:我说内个{老谁家小谁>啊,{上个月>的党费你想拖到什么时候啊?赶紧交!明天不把帐结清我卸了你家蟑螂的腿!!!
落款:大咖党党支部
(“老谁家小谁”用欠款大咖的姓名取代,excel表格统计出来的有周润发、周星驰和刘德华,虽然他们都是我小时候的偶像,但工作上我是一个有立场滴银:即除了领导,对谁都一视同仁。“上个月”用excel表格记录的最后一个月来替代)
python发短信到自己的手机上也很有用,比如我可以提醒自己在某个时间点干啥干啥;
再比如我有个抓取图片的爬虫程序,运行起来要很久很久,我就可以把发送短信的那几行代码贴到程序最后,这样程序运行完毕后会自己短信通知我,省得我守在电脑旁边,或不得不一遍一遍滴过来查看。
我得到了领导的夸奖,他语重心长滴对我说:"小拍呀,工作做滴不错!但你是不是得与时俱进呀,现在电子邮件和手机短信都没微信普及,你是不是让你的程序能发送微信啊 ......“
我惊呆了,后面的训话我一句没听见去
邮件和短信一起来:
# sendDuesReminders.py - Sends emails based on their status in spreadsheet.
import openpyxl, smtplib, sys
from email.mime.text import MIMEText
# Open the spreadsheet and get the latest dues status.
wb = openpyxl.load_workbook('duesRecords.xlsx')
sheet = wb.get_sheet_by_name('Sheet1')
lastCol = sheet.max_column
latestMonth = sheet.cell(row=1, column=lastCol).value
unpaidMembers = {}
# Check each member's payment status
for r in range(2, sheet.max_row + 1):
payment = sheet.cell(row=r, column=lastCol).value
if payment != 'paid':
name = sheet.cell(row=r, column=1).value
email = sheet.cell(row=r, column=2).value
if email != None:
unpaidMembers[name] = email
# Log in to email account.
smtpObj = smtplib.SMTP('smtp.gmail.com', 587)
smtpObj.starttls()
# smtpObj.login(This email address is being protected from spambots. You need JavaScript enabled to view it.', sys.argv[1])
smtpObj.login(This email address is being protected from spambots. You need JavaScript enabled to view it.', 'ikwanmgexipeygva')
# Send out reminder emails.
for name, email in unpaidMembers.items():
body = '\n我说内个{}啊,\n\n' \
' {}的党费你想拖到什么时候啊,赶紧交!明天不把帐结清我卸了你家蟑螂的腿!!!\n\n ' \
'大咖党党支部 '.format(name, latestMonth)
print('Sending email to {}...'.format(email))
#
msg = MIMEText(body)
msg['From'] = This email address is being protected from spambots. You need JavaScript enabled to view it.'
msg['To'] = email
msg['Subject'] = '拖欠的人是可耻的'
sendmailStatus = smtpObj.send_message(msg)
#
if sendmailStatus != {}:
print('There was a problem sending email to {}: {}'.format(email, sendmailStatus))
smtpObj.quit()
import sendMessage
message = '赶紧把大咖党党费交了!!!'
sendMessage.textMyself(message)
from twilio.rest import Client
# Your Account Sid and Auth Token from twilio.com/console
account_sid = "ACbe036e2467f6b1b9b7eea6be626ef0a7"
auth_token = "965ef4f100fe04b96a4b8886a7fd338d"
client = Client(account_sid, auth_token)
myTwilioNumber = '+15109013265'
myCellPhone = '+8613912345678'
# +86 13912345678
client.messages.create(to=myCellPhone, body='昨夜西风凋碧树,望断天涯路', from_=myTwilioNumber,)