擅长:python、mysql、java
<p>您要求<code>ord</code>根据字符串中的3个字符查找值。关于<a href="https://docs.python.org/2/library/functions.html#ord" rel="nofollow noreferrer">the ord function here.</a>的更多信息,在for循环中,您正在通过一个列表进行交互,因此展开的代码如下所示。在</p>
<pre><code>for s in ['ABC','CDE','FGH']:
print s+', ',
</code></pre>
<p>它将输出,<code>ABC, CDE, FGH</code>。要解决此问题,请在实际字符串上放置另一个for循环,或者将原始列表合并为一个字符串。在</p>
<p>1)另一个for循环。在</p>
^{pr2}$
<p>2)实际字符串。在</p>
<pre><code>str = ''.join(s for s in str)
print ' '.join(format(ord(stirng), 'b') for string in str)
</code></pre>