hard way learning python 0731
来源:互联网 发布:淘宝美工字体库百度云 编辑:程序博客网 时间:2024/06/06 02:37
try用法:
a = 0
b = 5
try:
c= a / b
print c
except :
print a,b
else:
print "no error"
finally:
print "end"
lambda用法:
用来定义一些简单的函数
my_lambda = lambda arg : arg+1
print my_lambda(7)
is:
python中,一个对象的属性包括了id、type和value
我们用 == 表示数值上的相等,而用is还判断两个是不是同一个对象
raise:
用于中断程序并在终端上报这个错
raise NameError
Traceback (most recent call last):
File "F:/pythonWorkspace/project0730/test0730", line 16, in <module>
raise NameError
NameError
exec:
输入一个字符串类型的命令,使用exec("command") 来执行相关的命令
pass:
python中的占位符号,无任何意义
yield:
python中的迭代器,在一个普通函数中放入 yield a 语句
该函数会持续不断的返回 内容为a 的迭代数据
global:
在函数中使用全局变量时需要在使用前先执行 global var 指令
List:
a = ["as","bb","sd","sfg","sf","afaga"]
字典:
a = {'name':'zed' , 'age':'36'}
如果需要添加,只需要直接 a['city'] = "AA" 即可
删除时则使用 del a["city"]
若想循环使用字典内的内容 可以使用 a.items()
可使用[] 加上下标进行访问
a = 0
b = 5
try:
c= a / b
print c
except :
print a,b
else:
print "no error"
finally:
print "end"
lambda用法:
用来定义一些简单的函数
my_lambda = lambda arg : arg+1
print my_lambda(7)
is:
python中,一个对象的属性包括了id、type和value
我们用 == 表示数值上的相等,而用is还判断两个是不是同一个对象
raise:
用于中断程序并在终端上报这个错
raise NameError
Traceback (most recent call last):
File "F:/pythonWorkspace/project0730/test0730", line 16, in <module>
raise NameError
NameError
exec:
输入一个字符串类型的命令,使用exec("command") 来执行相关的命令
pass:
python中的占位符号,无任何意义
yield:
python中的迭代器,在一个普通函数中放入 yield a 语句
该函数会持续不断的返回 内容为a 的迭代数据
global:
在函数中使用全局变量时需要在使用前先执行 global var 指令
List:
a = ["as","bb","sd","sfg","sf","afaga"]
字典:
a = {'name':'zed' , 'age':'36'}
如果需要添加,只需要直接 a['city'] = "AA" 即可
删除时则使用 del a["city"]
若想循环使用字典内的内容 可以使用 a.items()
可使用[] 加上下标进行访问
阅读全文
0 0
- hard way learning python 0731
- ex26 learning python the hard way新连接
- Learning XXX the hard way系列
- Learn Python The Hard Way
- Learn Python The Hard Way
- learning python in the hard way习题1~5的附加题练习
- learning python in the hard way习题6~10的附加题练习
- learning python in the hard way习题11~15的附加题练习
- 《learning python the hard way》习题46 项目骨架搭建 问题小结(一)之软件包的安装
- 《learning python the hard way》习题46 项目骨架搭建 问题小结(二)之 自动化测试代码问题
- Learn Python the Hard Way ex48
- 学《learn python the hard way》(3)
- learn python the hard way 的ex48
- Learn Python The Hard Way-Ecercise1~5
- Learn Python The Hard Way-Ecercise6~10
- Learn Python The Hard Way-Ecercise11~15
- Learn Python The Hard Way-Ecercise16~20
- Learn Python The Hard Way-Ecercise21~25
- ccf认证工资计算
- MySQL收回权限
- linux文件上传下载
- 方法重载和方法重写
- 简单的投票软件
- hard way learning python 0731
- 算法导论思考题6-3:Young氏矩阵
- Spark SQL 物理执行计划各操作实现
- iphone4越狱后找不到可以安装的openssh
- 学习Retrofit_持续性更新
- Windows环境配置:安装配置IIS和PHP
- docker容器简介
- 一张图读通Spark源码
- Mysql数据库表分区存储到指定磁盘路径