2016-08-23 9 views
0

私のコードがうまくいかない理由がわかりません。私はそれを私のインストラクターから逐語的にコピーしました。私の出力が予期しない結果を投げているのはなぜですか?

import urllib 

def read_text(): 
    quotes = open("C:\Users\Kyle\Desktop\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.wdyl.com/profanity?q="+text_to_check) 
    output = connection.read() 
    print(output) 
    connection.close() 

read_text() 

そして出力:

<html><head> 
    <meta http-equiv="content-type" content="text/html;charset=utf-8"> 
    <title>404 Not Found</title> 
    </head> 
    <body text=#000000 bgcolor=#ffffff> 
    <h1>Error: Not Found</h1> 
    <h2>The requested URL <code>/profanity?q=shot</code> was not found on this server.</h2> 
    <h2></h2> 
    </body></html> 

ですが、なぜでしょうか?

ありがとうございました!

+0

テキストファイルのサンプルコンテンツを提供してください。 – albert

+1

http://www.wdyl.com/有効な場所ではないようです。 –

+0

WYDLはもうアクティブではありません:https://en.wikipedia.org/wiki/WDYL_(search_engine) – albert

答えて

関連する問題