代码提供了三种基本方法连接字符串和数字,效率各有不同
#!/usr/bin/env python # # [代码名字: String and number concatenation] # [代码分类: Python Core] # [代码描述: Concatenate a string and a number] # [代码作者: Jono Bacon <jono@ubuntu.com>] # [代码协议: GPL] x = 1 print str(x) + " is a string" print "%s is a string" % x print x, "is a string"