[python]python的格式输出

来源:互联网 发布:c网络语言是什么意思 编辑:程序博客网 时间:2024/06/04 19:56

示例代码:

str = "hello_world"

print "%s"%str

print ("%s"%str)


输出结果:

hello_world
hello_world


第一个%s表示按照字符串输出

第二个%是链接符,其后的内容是待输出的内容,可以理解为c语言中的逗号


使用注意:

链接符后面的待输出内容,最好用括号括起来。避免错误。

print "%s, %s"%(str,str2)    输出:hello_world, welcome here!





原创粉丝点击