首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Twilio和Beautiful Soup发回语法错误

Twilio和Beautiful Soup发回语法错误
EN

Stack Overflow用户
提问于 2017-03-13 13:19:39
回答 1查看 50关注 0票数 0

我正在使用Python运行BeautifulSoup和Twilio,以此作为识别我所在地区免费食物的一种方式。

我正在使用下面的代码,这些代码是我用notepad++编写的,然后在我的downloads文件夹中保存为experiment.py。

代码语言:javascript
复制
from bs4 import BeautifulSoup
import requests
from twilio.rest import TwilioRestClient
import re

url = 'https://postmates.com/new-york-city'
account_sid = 'XXX'
auth_token = 'XXX'
twilio_phone_number = '+15551254565'
my_phone_number = '+15551234567'

webpage = requests.get(url)
soup = BeautifulSoup(webpage.text, 'html.parser')

free_regex = re.compile('free')
all_strings = list(soup.stripped_strings)
free_food = [s for s in all_strings if free_regex.match(s.lower())]

if free_food:
body = 'Free Postmates!\n\n' + '\n'.join(free_food)
client = TwilioRestClient(account_sid, auth_token)
client.messages.create(
    body=body,
    to=my_phone_number,
    from=twilio_phone_number
)

当我尝试在终端中通过输入cd downloads experiment.py来运行这个命令时,我得到了以下消息。

文件"experiment.py",第25行from=twilio_phone_number ^ SyntaxError:无效语法

是什么导致了这种情况的发生。我在这里看不到语法错误。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-03-13 13:22:27

代码语言:javascript
复制
from=twilio_phone_number

from是python中的一个关键字,将其更改为from_或其他什么。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42757079

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档