下面是我的python代碼來檢查文件中的罵人詞。 但我無法找到爲什麼編譯器顯示錯誤:module 'urllib' has no attribute 'urlopen'
。我的代碼urlopen函數有什麼問題?
import urllib
def read_txt():
quote = open("c:\\read.txt") #for opening the file
content = quote.read() #for reading content in a file
print(content)
quote.close() #for closing the file
check_profanity(content)
def check_profanity(text):
connection = urllib.urlopen("https://www.wdylike.appspot.com/?q=" + text)
ouput = connection.read()
print(output)
connection.close()
read_txt()
? –