python中数字和字符串连接的方法的代码

将写代码过程经常用到的代码片段珍藏起来,如下代码段是关于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 <jono@ubuntu.com>]
# [SNIPPET_LICENSE: GPL]


x = 1

print str(x) + " is a string"
print "%s is a string" % x
print x, "is a string"




 

posted @ 2021-11-24 23:53  androidyou  阅读(170)  评论(0编辑  收藏  举报