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

时间:2014-06-27 17:17:03

标签: python urllib eol

伙计们,所以我学习Python并且我已经编写了这个程序:

import urllib

def read_text():
  quotes = open(r"C:\moviequotes\moviequotes.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)

1 个答案:

答案 0 :(得分:1)

交换:

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)

你有一个额外的双引号。