前提・実現したいこと
プログラミング初めて20日
progateで学びました。
pythonを学んでいるので以下のものを作ろうと思いましたがエラーが出て進めません。
どうしたら良いでしょうか?
Python初心者に送る「人工知能の作り方」http://sandmark.hateblo.jp/entry/2017/10/07/141339
エディタはAtomを使っています。
UdemyでAnaconda入れるものがあったので入れていますが何かよくわかっていないので入れているだけです。
発生している問題・エラーメッセージ
エラーメッセージ
>>> from main import Responder >>> oumu = Responder('Oumu-Gaeshi') ``````←ここがうまくいってないみたいです Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/########/Desktop/repos/unmo/main.py", line 8, in __init__ self._name = name AttributeError: can't set attribute ```ここに言語名を入力 python ソースコード ![イメージ説明](46d80871cd382f9e3337d615317ce704.png)
class Responder:
#AIの応答を制御するクラス
#プロパティ:
#name -- Responderオブジェクトの名前
def __init__(self,name): # 文字列を受け取り、自身のnameに設定する。 self._name = name def response(self,text): #ユーザーからの入力(text)を受け取り、AIの応答を生成して返す。 return '{}ってなに?'.format(text) @property def name(self): # オブジェクトの名前 return self._name
AttributeError: can't set attributeと File "<stdin>", line 1, in <module>で Googleで検索してみましたが解決策を見つけられませんでした。 初歩的な問題かもしれませんがよろしくお願いします。
回答1件
あなたの回答
tips
プレビュー