Python程序教程

您现在的位置是:首页 >  Python

当前栏目

Python基本数据类型-字符型

Python,基本,数据类型,字符
2025-03-18 08:48:47 时间

一、什么是字符串?

字符串是以单引号或者双引号括起来的任意文本

str1 = 'zutuanxue is a good man'
str2 = "zutuanxue is a nice man"

注意:

​1、引号本身是一种表现形式,不属于字符串的内容 ​2、如果字符串本身带单引号,外侧用双引号包裹起来(“he’s a good man”)

二、多行字符

以’’'或者"""引起来的任意文本

str3 = '''
good
nice
cool
handsome'''

str4 = """
good
nice
cool
handsome"""