思路:
读取文本 -> 检查文本 -> 判断输出
import urllib
def read_text():
quotes = open("/Users/gloriazhang/Documents/movie_quotes.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("http://www.wdylike.appspot.com/?q="+text_to_check)
output = connection.read()
#print(output)
if "true" in output:
print("Profanity!")
elif "false" in output:
print("This ducument has no curse words!")
else:
print("Could not scan")
connection.close()
read_text()