我目前正在通过Udacity学习Python,它为check_profanity提供了一个NameError,我不确定为什么
import urllib
def read_text():
quotes = open("C:\\Udacity Python\\Lesson 4\\movie_quotes.txt", "r")
contents = quotes.read()
print(contents)
quotes.close()
check_profanity(contents)
read_text()
def check_profanity(contents_of_file):
text_to_check = read_text.contents_of_file
connection = urllib.urlopen(
"http://www.wdylike.appspot.com/?q="+text_to_check)
output = connection.read()
print(output)
connection.close()
check_profanity()