<p>我是编程新手,并在这行上盖章:</p>
<pre><code>print('My name is')
for i in range(5):
print('Jimmy Five Times (' + str(i) + ')')
</code></pre>
<p>我不理解这部分('+str(I)+'),更具体地说,str(I)前后的+符号[特别是str(I)后的+符号]</p>
<p>我知道+符号表示字符串串联,但在上面的一行中,什么与什么结合</p>
<p>第一个例子和第二个例子有什么区别</p>
<pre><code>print('My name is')
for i in range(5):
print('Jimmy five times ' + str(i))
</code></pre>
<p>有人能举一个类似但复杂的例子来说明这种用法吗</p>
<p>谢谢</p>
<p><strong>编辑:</strong>
我意识到字符串是<strong>吉米五次(</strong>,而不是<strong>吉米五次(</strong>),左括号和右括号把我弄糊涂了。谢谢大家的快速回复</p>
<p>字符串上下文中的符号<code>+</code>用于字符串连接</p>
<p>具体地说,在本例中,<code>+</code>操作数不是为string和int定义的(<code>i</code>是一个整数),因此您首先必须将其转换为string by <code>str(i)</code>,然后才能联系字符串</p>