python-3.x - 为什么会发生此 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()
解决方案
推荐阅读
- docker - 备份 docker 卷 - 简单的 tar 归档还不够吗?
- c# - 无法保存来自 EditText 的数据
- python - 字典值输入不同,输出不同
- javascript - axios 和 jQuery 发布格式
- python - 如何在变量名中集成不断变化的索引?
- jenkins - 在 Jenkins 中,我可以通过显示名称找到工作吗?
- android - 我的 App 小部件的 Remoteview 接收器随机接听电话
- php - 单选按钮位于文本条支付通道上方-woocommerce
- android-volley - 使用 Volley 在 android 中解析 JSON 数组数据
- mysql - 在给定距离处查找彼此远离的表格中的坐标