一、while循环与使用场景

CONDITION=1

while CONDITION <=5 :
CONDITION +=1
print("hello")
else:
print("EOF") hello
hello
hello
hello
hello
EOF

二、for与for-else循环

# 主要是用来遍历/循环 序列或者集合、字典

a=[["a","b","c","d"],(1,2,3)]

for x in a:
for y in x:
print(y)
# print(y,end='') #end 在一行 打印
else:
print("fruit is gone")
结果: a
b
c
d
1
2
3
fruit is gone

break 终止当前循环

continue 终止出本次循环

a=[["a","b","c","d"],(1,2,3)]

for x in a:
for y in x:
if y == 'b':
break
print(y)
else:
print("fruit is gone") a
1
2
3
fruit is gone
a=[["a","b","c","d"],(1,2,3)]

for x in a:
for y in x:
if y == 'b':
continue
print(y)
else:
print("fruit is gone") a
c
d
1
2
3
fruit is gone

三、for 与 range

for x in range(0,10,2):
print(x, end=' | ' )
0 | 2 | 4 | 6 | 8 |
a=[1,2,3,4,5,6,7,8]

for i in range(0,len(a),2):
print(a[i],end=' | ') 1 | 3 | 5 | 7 |
b=a[0:len(a):2]
print(b) [1, 3, 5, 7]

四、新篇章导言

高性能、封装性(可复用)、抽象

直白、美与不美

五、Python工程的组织结构:包、模块儿、类

包 模块 类  函数、变量

六、Python包与模块的名字

包的名字就是文件夹的名字

模块的名字就是文件的名字

在一个文件夹里面存在 _init_.py  文件 就是包

七、import导入模块

import 模块名 as 自定义命名

八、from import 导入变量

from  包名 /模块名 import 具体变量名/模块名/*(全部引入)

__all__ =['a','c']  模块的内置导入变量。

九、__init__.py 的用法

VSCode  去掉 __pycache__ 文件夹,在设置里面搜索

"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/__pycache__":true
}

from c1 import a,b,\c

from c1 import (a,b,c) 换行

__init__.py  在导入包或者包中的模块的时候 自动运行包包含其中的 __init__.py文件

批量导入包

十、 包与模块的几个常见错误_

包和模块是不会 重复导入的

避免循环导入

十一、模块内置变量

十二、入口文件和普通模块内置变量的区别

十三、__name__的经典应用

十四、相对导入和绝对导入 一

十五、相对导入和绝对导入 二

最新文章

  1. mysql 错误 ERROR 1372 (HY000): Password hash should be a 41-digit hexadecimal number 解决办法
  2. java从基础知识(十)java多线程(下)
  3. 改变按钮在iPhone下的默认风格
  4. Devexpress Ribbon
  5. 利用session完成用户登陆
  6. maven An error occurred while filtering resources
  7. SessionHelper
  8. Redis基础教程
  9. 004 range的用法
  10. poj2405---体积几何
  11. C# 开发系列(二)
  12. 浅析Struts2中的OGNL和ValueStack
  13. 七牛php-sdk使用-在线打包
  14. Mysql数据库基础学习笔记
  15. 微信小程序高级基础
  16. io系列之字节流
  17. mysql登录报错:ERROR 1045 (28000): Access denied for user &#39;root&#39;@&#39;localhost&#39; (using password: YES)
  18. centos 7 之nginx
  19. Linux常用指令笔记
  20. npm 升降级

热门文章

  1. c++ 子类构造函数初始化及父类构造初始化
  2. nginx和apache作为webserver的差别
  3. Qt 5.3 下OpenCV 2.4.11 开发(5)最高效的像素引用
  4. JBOSS部署项目之后,无法通过IP地址訪问,仅仅能通过localhost或者127.0.0.1訪问
  5. Visual Assist X 10.8.2036的Crack破解补丁.2014.05.22 (General release.)
  6. zoj_3735,dp,长沙站j题
  7. python 同步IO
  8. NOIP2017 小凯的疑惑 解题报告(赛瓦维斯特定理)
  9. String methods
  10. JavaScript中函数作为另一个函数的参数的时候它存在于哪个作用域