をしたときに属性がこのクラスに存在しないというエラーコードがあります。 PYなぜそれが明確に私はこれらは以下の私のファイルであるPythonの2.7.13 を使用しています
import webbrowser
class Movie():
def __init__(self, movie_title, movie_storyline, poster_image, trailer_youtube):
self.title = movie_title
self.storyline = movie_storyline
self.poster_image_url = poster_image
self.trailer_youtube_url = trailer_youtube
def show_trailer(self):
webbrowser.open(self.trailer_youtube_url)
C:\ PROJECTS \ movies_pythonproject \ entertainmentcenter.py
import media
Above_The_Law = media.Movie("Above The Law",
"A former Special Operations Vietnam vet works as a
Chicago cop and uncovers CIA wrongdoing.",
"https://images-na.ssl-images-amazon.com/images/M/MV5BYTgyYTIyOTMt[email protected]._V1_UY268_CR0,0,182,268_AL_.jpg",
"https://youtu.be/GZjl-UT4-o4")
Above_The_Law.show_trailer()
私はコンソールが私にこのエラーが発生しますentertainmentcenter.py実行します。
Traceback (most recent call last):
File "C:/PROJECTS/movies_pythonproject/entertainment_center.py", line 8, in
<module>
Above_The_Law.show_trailer()
AttributeError: Movie instance has no attribute 'show_trailer'
>>>
インデント! 関数は '__init__'の中にネストされています –
あなたはインデントが間違っています –
これは実際には私の間違いだったこの問題を書いて、申し訳ありません。私のコードを見てください(私はそれを編集して修正しましたが、まだエラーを表示しています) –