Skip to content

Commit

Permalink
Merge branch 'master' of github.com:TwoWater/Python
Browse files Browse the repository at this point in the history
  • Loading branch information
walter201230 committed Jul 28, 2020
2 parents 8d2dda9 + 7eb243f commit 2165e2d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 17 deletions.
16 changes: 8 additions & 8 deletions Article/PythonBasis/python7/3.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 三、lsit 生成式(列表生成式) #
# 三、list 生成式(列表生成式) #


## 1、创建 list 的方式 ##
Expand Down Expand Up @@ -48,7 +48,7 @@ print('\n'.join([' '.join ('%dx%d=%2d' % (x,y,x*y) for x in range(1,y+1)) for y

## 2、list 生成式的创建 ##

首先,lsit 生成式的语法为:
首先,list 生成式的语法为:

```python
[expr for iter_var in iterable]
Expand All @@ -65,8 +65,8 @@ print('\n'.join([' '.join ('%dx%d=%2d' % (x,y,x*y) for x in range(1,y+1)) for y

```python
# -*- coding: UTF-8 -*-
lsit1=[x * x for x in range(1, 11)]
print(lsit1)
list1=[x * x for x in range(1, 11)]
print(list1)
```

输出的结果:
Expand All @@ -79,8 +79,8 @@ print(lsit1)

```python
# -*- coding: UTF-8 -*-
lsit1= [x * x for x in range(1, 11) if x % 2 == 0]
print(lsit1)
list1= [x * x for x in range(1, 11) if x % 2 == 0]
print(list1)
```

输出的结果:
Expand All @@ -95,8 +95,8 @@ print(lsit1)

```python
# -*- coding: UTF-8 -*-
lsit1= [(x+1,y+1) for x in range(3) for y in range(5)]
print(lsit1)
list1= [(x+1,y+1) for x in range(3) for y in range(5)]
print(list1)
```

输出的结果:
Expand Down
2 changes: 1 addition & 1 deletion Article/PythonBasis/python8/1.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Python 就是一门面向对象的语言,

如果你学过 Java ,就知道 Java 的编程思想就是:万事万物皆对象。Python 也不例外,在解决实际问题的过程中,可以把构成问题事务分解成各个对象。

面向对象都有两个基本的概率,分别是类和对象。
面向对象都有两个基本的概念,分别是类和对象。

* ****

Expand Down
4 changes: 2 additions & 2 deletions Article/PythonBasis/python8/3.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ class 就是类,method 就是方法。

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

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


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

省了都会报错。

Expand Down
6 changes: 1 addition & 5 deletions Article/codeSpecification/codeSpecification_first.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ def main():
* 可以使用多个空行分隔多组相关的函数
* 函数中可以使用空行分隔出逻辑相关的代码

### 2.5、编码

* 文件使用 UTF-8 编码
* 文件头部加入`#-*-conding:utf-8-*-`标识

## 3、import 语句

Expand Down Expand Up @@ -258,4 +254,4 @@ Optional plotz says to frobnicate the bizbaz first.
"""

"""Oneline docstring"""
```
```
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ IT 行业相对于一般传统行业,发展更新速度更快,一旦停止
* [迭代器和生成器](/Article/PythonBasis/python7/Preface.md)
- [迭代](/Article/PythonBasis/python7/1.md)
- [Python 迭代器](/Article/PythonBasis/python7/2.md)
- [lsit 生成式(列表生成式)](/Article/PythonBasis/python7/3.md)
- [list 生成式(列表生成式)](/Article/PythonBasis/python7/3.md)
- [生成器](/Article/PythonBasis/python7/4.md)
- [迭代器和生成器综合例子](/Article/PythonBasis/python7/5.md)
* [面向对象](/Article/PythonBasis/python8/Preface.md)
Expand Down

0 comments on commit 2165e2d

Please sign in to comment.