大多数程序都定义并收集某种数据,然后使用它们来做些有意义的事情。
鉴于此,对数据进行分类大有裨益。
我们将介绍的第一种数据类型是字符串,字符串虽然看似简单,但能够以很多不同的方式使用它们。
字符串就是一系列字符,在Python中,用引号括起来的都是字符串,其中的引号可以是单引号,也可以是双引号,如下所示:
“This is a string."
'This is also a string'
这中灵活性让你能够在字符串中包含引号和撇号:
'I told my friend,"Python is my favorite language!"'
"The language 'Python' is named after Monty Python, not the snake."
"One of Python's strengths is its diverse and supportive community."
