首页 > 解决方案 > 为什么会发生此 NameError?

问题描述

我目前正在通过 Udacity 学习 Python,它给了我一个 NameError for check_profanity,我不确定为什么

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()

标签: python-3.x

解决方案


推荐阅读