主页
Python
Python String format() 方法
demo_string_placeholder4
运行 ❯
×
更改方向
保存代码
更改主题
#To demonstrate, we insert the number 8 to specify the available space for the value. #Use "=" to place the plus/minus sign at the left most position: txt = "The temperature is {:=8} degrees celsius." print(txt.format(-5))
The temperature is - 5 degrees.