f前缀用来格式化字符串
>>> name = 'Xiaoming'
>>> age = 18
>>> f'He said his name is {name} and he is {age} years old.'
He said his name is Xiaoming and he is 18 years old.
f前缀可以简单有效的格式化字符串,比起format()方法具备更好的可读性
>>> name = 'Xiaoming'
>>> age = 18
>>> 'He said his name is {} and he is {} years old.'.format(name, age)
'He said his name is Xiaoming and he is 18 years old.'
>>> name = 'Xiaoming'
>>> seven = 8
>>> f'''He said his name is {name.upper()}
... and he is {6 * seven} years old.'''
'He said his name is XIAOMING
and he is 48 years old.'
面向对象编程
-
类: 用来描述具有相同属性和方法的对象的集合,类定义了集合中每个对象共有的属性和方法,对象时类的实例
-
类变量(属性): 类变量在整个实例化的对象中是公用的,类变量定义在类中,且在方法之外.类变量通常不作为实例变量使用,类变量也成为属性
-
数据成员: 类变量或实例变量用于处理类及其实例对象的相关数据
-
实例变量: 定义在方法中的变量只作用于当前实例的类
-
实例化: 创建一个类的实例,类的具体对象
-
方法: 类中定义的函数
-
对象: 通过类定义的数据结构实例,对象包括两个数据成员(类变量个实例变量)和方法
-