-2
我想輸出是這個如何在包含'%s'的字符串中打印'%'?
我使用「%s」來打印出來:你好!
我的代碼:
print "I'm using %s to print this out: %s" % "hello!"
這將返回一個錯誤。
我想輸出是這個如何在包含'%s'的字符串中打印'%'?
我使用「%s」來打印出來:你好!
我的代碼:
print "I'm using %s to print this out: %s" % "hello!"
這將返回一個錯誤。
字面一個前把第二個%
:
print "I'm using %%s to print this out: %s" % "hello!"
這不是一個特定Python的溶液:C的printf
,和其它的類似物(如殼printf
)相同的方式工作。
謝謝,這工作。 –
雖然這個問題的詳細程度不需要這個問題,「它返回一個錯誤」不是很有用。精確地顯示*您嘗試的內容,以及*完全*錯誤是什麼。 –
你可以使用格式代替 – SirParselot