擅长:python、mysql、java
<blockquote>
<p>when I run that it spits out a string, qkxfdqp5jockf6n for example. I want to take that be able to do something like print "Hello, %s" and it say "Hello, qkxfdqp5jockf6n"</p>
</blockquote>
<p><code>%s</code>不是魔法,它不知道你想用什么来代替它。它是一个占位符。将字符串替换为该字符串的方式与替换其他字符串的方式相同:</p>
<pre><code>text = 'Damien'
def my_function():
return 'Damien'
# All of the following will print "Hello, Damien":
print 'Hello, %s' % 'Damien'
print 'Hello, %s' % text
print 'Hello, %s' % my_function()
</code></pre>
<p>没有任何东西“变成”转换说明符。在</p>