Skip to content

Commit 8349428

Browse files
authored
Update 3.md
1 parent e35ed12 commit 8349428

File tree

1 file changed

+2
-2
lines changed
  • Article/PythonBasis/python8

1 file changed

+2
-2
lines changed

Article/PythonBasis/python8/3.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ class 就是类,method 就是方法。
2929

3030
因此类方法,想要调用类属性,需要以下步骤:
3131

32-
* 在方法上面,用 `@classmethon` 声明该方法是类方法。只有声明了是类方法,才能使用类属性
32+
* 在方法上面,用 `@classmethod` 声明该方法是类方法。只有声明了是类方法,才能使用类属性
3333
* 类方法想要使用类属性,在第一个参数中,需要写上 `cls` , cls 是 class 的缩写,其实意思就是把这个类作为参数,传给自己,这样就可以使用类属性了。
3434
* 类属性的使用方式就是 `cls.变量名`
3535

3636

37-
记住喔,无论是 `@classmethon` 还是 `cls` ,都是不能省去的。
37+
记住喔,无论是 `@classmethod` 还是 `cls` ,都是不能省去的。
3838

3939
省了都会报错。
4040

0 commit comments

Comments
 (0)