将写代码过程经常用到的代码片段珍藏起来,如下代码段是关于python中数字和字符串连接的方法的代码,应该对各位有些用途。
#!/usr/bin/env python
[SNIPPET_NAME: String and number concatenation]
[SNIPPET_CATEGORIES: Python Core]
[SNIPPET_DESCRIPTION: Concatenate a string and a number]
[SNIPPET_AUTHOR: Jono Bacon <@ubuntu.com>]
[SNIPPET_LICENSE: GPL]
x = 1
print str(x) + " is a string"
print “%s is a string” % x
print x, “is a string”