擅长:python、mysql、java
<p>在Python中还有几种方法:</p>
<pre><code>print "let's talk about this %s" % my_name
print "let's talk about this {:s}".format(my_name)
print "let's talk about this", my_name
</code></pre>
<p>它们都产生相同的输出。但是,鼓励使用<a href="http://docs.python.org/library/string.html#string-formatting" rel="nofollow">.format</a>方法(从pythonv2.6开始就可用)而不是老式的<code>%</code>(引用<a href="http://docs.python.org/py3k/whatsnew/3.0.html" rel="nofollow">What's New in 3.0</a>:“<em>。%运算符仍然受支持;它将在python3.1中被弃用,稍后会从语言中删除。</em>“)</p>
<p>最后,在pythonv3.x中,<code>print</code>是一个函数,因此所有print语句都需要<code>()</code>。在</p>