使用urllib时扫描屏幕文字时的EOL.urlopen (PYTHON)



伙计们,我正在学习Python,我写了这个程序:

import urllib
def read_text():
  quotes = open(r"C:moviequotesmoviequotes.txt")
  contents_of_file = quotes.read()
  print(contents_of_file)
  quotes.close()
  check_profanity(contents_of_file)
def check_profanity(text_to_check):
  connection = urllib.urlopen(r"http://www.wdyl.com/profanity?q="+text_to_check")
  output = connection.read()
  print(output)
  connection.close()
read_text()

我得到这个错误:EOL,而扫描字符串文字。我做错了什么?这是文件:

-- Houston, we have a problem. (Apollo 13)
-- Mama always said, life is like a box of chocolates. You never know what you are       going to get. (Forrest Gump)
-- You cant handle the truth. (A Few Good Men)
-- I believe everything and I believe nothing. (A Shot in the Dark)

Exchange:

connection = urllib.urlopen(r"http://www.wdyl.com/profanity?q="+text_to_check")

connection = urllib.urlopen(r"http://www.wdyl.com/profanity?q="+text_to_check)

你有一个额外的双引号

最新更新