<p>我试图创建一个内置方法的字典,但是我得到了如下所示的输出。为什么会这样?我只想明白。在</p>
<pre><code>>>>
>>> dict = {'a': print('avc'), 'b': print('bbbb'), 'c': print('aaa')}
avc
bbbb
aaa
>>> dict
>>> {'a': None, 'b': None, 'c': None}
>>>
</code></pre>
<p>另外,如果有人想了解我的来历,他们可以看看这个问题:
<a href="https://www.hackerrank.com/challenges/python-lists" rel="nofollow">Link to the question I was trying to solve when I thought the above would be useful.</a></p>
<p>Print不返回值。在</p>
<p>想象一下它的定义是这样的</p>
<pre><code>(void) print(object):
do magic io stuff to make object appear in the console
</code></pre>
<p>因此,当您为字典中的键“a”分配print('avc')时,它会得到一个none。在</p>