擅长:python、mysql、java
<p>你打错电话了。你知道吗</p>
<p>尝试:</p>
<pre><code>>>>a = Cool('diana', 1234, {})
</code></pre>
<p>更多建议:</p>
<pre><code>class Cool():
def __init__(self, name, student_num, new_dict):
self._key = name
self._value = student_num
self._new_dict = new_dict
def get_name(self):
return self._key
def get_student_number(self):
return self._value
def get_dict(self):
self._new_dict[self._key] = self._value
return self._new_dict[self._key]
def __str__(self):
return str(self._new_dict[self._key])
</code></pre>
<p>为了让<code>print</code>工作(代码当前的方式)。你得先打电话给我</p>
<p>您可以只执行以下操作:</p>
<pre><code>a = Cool('diana', 1234, {})
print(a.get_dict())
</code></pre>
<p>或者你可以编辑你的代码来处理dict。你知道吗</p>