1. 字符串的定义
字符串是由字母、数字和特殊字符来组成的序列。
2. 创建字符串
如何创建字符串?
——使用 单引号、双引号或者三引号。
name = 'bornforthis'
number = "18"
paragraph = '''Hello,Bornforthis!
Hello,World!'''
paragraph_two = """Hello,Bornforthis!
Hello,World!"""
原创...大约 20 分钟
字符串是由字母、数字和特殊字符来组成的序列。
如何创建字符串?
——使用 单引号、双引号或者三引号。
name = 'bornforthis'
number = "18"
paragraph = '''Hello,Bornforthis!
Hello,World!'''
paragraph_two = """Hello,Bornforthis!
Hello,World!"""
假如,你是班级当中的课代表,每个月需要统计班级中每个学生的月考成绩。月考成绩会每个月一张纸,每张纸上都会依次记录每个学生的成绩越到成绩,例如:
某一天,老师要看刘奕彤 1月、2月、3月的成绩,这个时候作为课代表的你需要怎么办。——总不能直接把每个月的月考成绩单直接给老师,显然是不合适的。
In [2]: 1 + 1
Out[2]: 2
In [3]: 1 + 1.0
Out[3]: 2.0
In [4]: 2 - 1
Out[4]: 1
In [5]: 2 - 1.0
Out[5]: 1.0
In [6]: 2 * 1
Out[6]: 2
In [7]: 2 * 1.0
Out[7]: 2.0
In [8]: 2 * 1
Out[8]: 2
In [9]: 9 / 3
Out[9]: 3.0
int_num = 1
t = type(int_num)
print(int_num)
print("int num type is:>>>", t)
print("直接检测数据类型,并输出:>>>", type(int_num))
# output
1
int num type is:>>> <class 'int'>
直接检测数据类型,并输出:>>> <class 'int'>