当前位置:网站首页>类与对象笔记一
类与对象笔记一
2022-07-26 22:37:00 【久久鸭要变大鹅子】
类
class Dog:
cute = True
def have_it(doggy):
print('eating')
类的实例化
调用语法:实例名 = 类名()
意义:我们有了一个具体的实例,它可以调用所属类的所有属性和方法。
class Dog:
cute = True #这里是属性 狗勾可爱是True
def have_it(doggy): #这里是方法(类里的函数叫方法)
print('eating')
a = Dog() #类的实例化
print(a.cute) #打印类是属性
a.have_it() #调用类的方法
print(a)
创建一个类 —— 类的实例化 —— 用实例调用类的属性和方法。
创建类~~class 类名 :
编写类的属性
编写类里的方法(函数)
类的实例化~ 变量名=类名()
实例名.属性
实例名.方法()
边栏推荐
- MVC三层架构
- What is Tencent cloud lightweight application server? What are the differences between CVM and ECS?
- Deploy yolov5 error reporting in pycharm
- 滑动窗口问题总结
- [step by step, even thousands of miles] key words in the specified time period of the statistical log
- [netding Cup 2018] Fakebook records
- 分页插件--PageHelper
- Deep learning of parameter adjustment skills
- Relationship between limit, continuity, partial derivative and total differential of multivariate function (learning notes)
- [C language] array
猜你喜欢

Paging plug-in -- PageHelper

Question 141 of Li Kou: circular linked list

Midge paper reading notes

RecBole使用1

分页插件--PageHelper

Recbole use 1

Deploy yolov5 error reporting in pycharm

1、 Kubernetes basic concept + environment installation (build cross server public network environment)

Upload files to OSS file server

Complete backpack and 01 Backpack
随机推荐
Tensorflow2.0 deep learning simple tutorial of running code
SSRF (server side request forgery) -- Principle & bypass & Defense
Upload files to the server
Relationship between Unicode and UTF-8
Skiasharp's WPF self drawn bouncing ball (case version)
Transformers is a graph neural network
C and pointer Chapter 18 runtime environment 18.1 judgment of runtime environment
C and pointer Chapter 18 runtime efficiency 18.3 runtime efficiency
Push to origin/master was rejected error resolution
Codeforces E. maximum subsequence value (greed + pigeon nest principle)
Upload files to OSS file server
Pytorch data pipeline standardized code template
4. Talk about the famous Zhang Zhengyou calibration method
The place where the dream begins ---- first knowing C language (2)
The difference between SQL join and related subinquiry
RecBole使用1
In depth interpretation of the investment logic of the consortium's participation in the privatization of Twitter
机器学习模型——lightGBM
11_ Weather case - monitoring properties
嵌入式系统移植【8】——设备树和根文件系统移植