专栏名称: 开发者阿橙
致力于成为国内最好的Python开发者学习交流平台,这里有关于Python的国内外最新消息,每日推送有趣有料的技术干货和社区动态。 官方网站:www.python-cn.com
目录
相关文章推荐
Python爱好者社区  ·  太炸裂了!亚马逊云来了 ·  14 小时前  
Python爱好者社区  ·  全球首个满级QQ正式诞生!满级后长这样 ·  14 小时前  
Python大全  ·  Pandas玩转文本处理! ·  昨天  
Python大全  ·  用Python实现智能乒乓球游戏! ·  昨天  
Python大全  ·  用Python实现智能乒乓球游戏! ·  昨天  
Python爱好者社区  ·  很严重了,大家别轻易离职 ·  2 天前  
51好读  ›  专栏  ›  开发者阿橙

我是如何使用Python来自动化我的婚礼的

开发者阿橙  · 公众号  · Python  · 2017-04-16 21:02

正文

请到「今天看啥」查看全文


guest_name + ' telephone number empty not messaging'

  • wks_attendees . update_acell ( 'E' + str ( num ), '0' ) # set number to 0


  • else :

  • print 'Sending message to ' + guest_name

  • client . messages . create (

  • to = "+" + guest_number , # add the + back to make the number e.164

  • from_ = "" , # your twilio number here

  • body = message_body ,

  • )

  • wks_attendees . update_acell ( 'E' + str ( num ), int ( wks_attendees . acell ( 'E' + str ( num )). value ) + 1 ) # increment the message count row

  • else : # else part of the loop

  • print 'finished'

  • 因为短信可以看起来很简单,所以我添加了一些unicode来让它们有趣些。下面是幸运的受邀者接收到的短信样式:

    接下来,我使用Flask作为我的web服务器,然后设置我的Twilio消息请求URL指向/messages url,并创建简单的if语句来解析回复 (yes, no):hello_guest.py

    1. @app.route("/messages", methods=['GET', 'POST'])

    2. def hello_guest():


    3.    if "yes" in body_strip:

    4.        # We have a keeper! Find the attendee and update their confirmation_status

    5.        wks_attendees.update_acell("F"+str(guest_confirmation_cell.row), 'Accepted')  # update the status to accepted for that guest

    6.        resp.message(u"\u2665" + "Thanks for confirming, we'll be in touch!" + u"\u2665")  # respond to the guest with a confirmation!


    7.    elif "no" in from_body.lower():

    8.        # update the confirmation_status row to declined for that guest

    9.        wks_attendees.update_acell("F"+str(guest_confirmation_cell.row), 'Declined')

    10.        # respond to the user confirming the action

    11.        resp.message("Sorry to hear that, we still love you though!")


    12.    else:  # respond with invalid keyword

    13.        resp.message("You sent a different keyword, we need a yes or a no, you sent: "+  

    14.                     from_body)

    15.    return str(resp)

    第一条消息是在2月19日早上8:37的时候发送的,而在3分钟后,也就是早上8:40收到了第一条回复。到了早上9:38,我收到了23条确认回复,这可是32%的接受率!初始群发短信2天后,我们收到了58%的客人的确认!尽管取得了明显的成功,但是我的未婚妻并不热衷于我那作为婚礼邀请服务(SAAWIS?)的短信,因此,我决定添加一些功能到我的应用中。

    统计!我可以计算现场出席名单并按要求退回,给新娘即使反馈客人名单的成型。代码很简单,因为我已经在电子表格中设置了一些基本的计数器,因此,仅仅是抓取这些单元格的内容,并将其添加到短信中的事:hello_guest.py

    1. # attendance variables

    2. guest_confirmed = wks_attendees.acell('C70').value

    3. guest_unconfirmed = wks_attendees.acell('C71').value

    4. guest_no_response







    请到「今天看啥」查看全文


    推荐文章
    Python爱好者社区  ·  太炸裂了!亚马逊云来了
    14 小时前
    Python爱好者社区  ·  全球首个满级QQ正式诞生!满级后长这样
    14 小时前
    Python大全  ·  Pandas玩转文本处理!
    昨天
    Python大全  ·  用Python实现智能乒乓球游戏!
    昨天
    Python大全  ·  用Python实现智能乒乓球游戏!
    昨天
    Python爱好者社区  ·  很严重了,大家别轻易离职
    2 天前
    大家-腾讯新闻  ·  陈晓卿:咸淡水浸润的疍家美食
    8 年前
    每日币读  ·  币读微信群开门迎客!
    7 年前