【发布时间】:2017-03-05 19:36:29
【问题描述】:
我正在学习 Udacity 的课程,并且在尝试确定该站点的结果是返回 true 还是 false 时遇到了一些问题。我用下面的代码得到了 TypeError。
from urllib.request import urlopen
#check text for curse words
def check_profanity():
f = urlopen("http://www.wdylike.appspot.com/?q=shit")
output = f.read()
f.close()
print(output)
if "b'true'" in output:
print("There is a profane word in the document")
check_profanity()
输出打印b'true',我不太确定'b'来自哪里。
【问题讨论】:
标签: python-3.x urllib unicode-string