python中数字和字符串连接的方法的代码(Code for connecting numbers and strings in 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” % xprint x, “is a string”

————————

Collect the code snippets often used in the process of writing code. The following code snippet is about the method of connecting numbers and strings in Python. It should be useful to you. #/ 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” % xprint x, “is a string”