“`” 1.占位符%
%d 表示那个位置是整数;%f 表示浮点数;%s 表示字符串。
<pre><code>print('Hello,%s' % 'Python')
print('Hello,%d%s%.2f' % (666, 'Python', 9.99)) # 打印:Hello,666Python10.00
</code></pre>
2.format
<pre><code>print('{k} is {v}'.format(k='python', v='easy')) # 通过关键字
print('{0} is {1}'.format('python', 'easy')) # 通过关键字
</code></pre>
<pre><code> "“`
Was this helpful?
0 /
0