diff --git a/Article/PythonBasis/python7/3.md b/Article/PythonBasis/python7/3.md index 77fb5db6c6e6369184b8b3cef49a19c5f8b4cb0e..177ba14d2f59ef70bc53c51006e5a36f082402c5 100644 --- a/Article/PythonBasis/python7/3.md +++ b/Article/PythonBasis/python7/3.md @@ -1,4 +1,4 @@ -# 三、lsit 生成式(列表生成式) # +# 三、list 生成式(列表生成式) # ## 1、创建 list 的方式 ## @@ -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] @@ -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) ``` 输出的结果: @@ -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) ``` 输出的结果: @@ -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) ``` 输出的结果: diff --git a/README.md b/README.md index da008c954b851b2065d92fbfeaf904d406ef9019..a9df880e5a8f8ae83962815e6da2c38c01cfae55 100644 --- a/README.md +++ b/README.md @@ -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)