- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
python学习笔记(Python learning notes)
python学习笔记(Python learning notes)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # python学习笔记 (): 元组 []: 列表 {}: 字典 # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
格式:
if on:
(空格) xxxxx
或者
def on:
(空格) xxxxx
还有
for on:
(空格) xxxxx
一句话 有冒号的下一行往往要缩进, 该缩进就缩进
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
常用函数:
input ()
type (): 查询类型
id (): 查找存储空间
range (10)
print (% d:% d% (3,4))
reduce (): 为逐次操作list里的没项, 接收的参数为2个, 最后返回的为为一个结果
--------------------------------------------------------------------
内建数据类型
boolean 布尔型
integer 整形
float 浮点型
string 字符串
tuple 原组
list 列表
dict 字典
seen 集合: 唯一的不能重复
none 空字符串 , 空元组 () 、空列表 [] 、空字典 {} = = false
--------------------------
第一节: 『序列』 (字符串, 数组, 元组)
性质: 不可变
基本函数: len ()
max () () my
基本操作:
【取值】切片、索引 str [first: than: steps]
【查找】
was in str
---------------------------
第二节: 『列表』
性质: 可变
基本操作:
【取值】
a.切片、索引 b.list []
【添加】
list.append ()
【删除】
part (list [])
list.remove (list [])
【修改】
list [] = x
list.insert (index, object): 在指定位置插入成员
list.reverse (): 翻转
list.pop (index): 指定弹出元组的成员
list.clear (): 清空元组
list.count ()
【查找】
was in list
--------------------------
第三节『函数』:
形式: def function (arg1 [, arg2..argn]):
(空格)
a.多类型传值:
def f3 (x, y):
print (x + y)
【传元组】: 必须存在, 且一一对应
t = (a , b )
f3 (* t)
【传字典】: 必须存在, 且一一对应
your = {name: electricity, age: 20}
function (* * d2)
b.处理多余实参
以【元组】方式处理
def f5 (x, * args):
print (x)
print (args)
以【字典】方式处理
def f5 (x, * args, * * kwargs):
print (x)
print (args)
print (kwargs)
c.lambda表达式 (匿名函数)
lambda语句中, 冒号前是参数, 可以有多个, 用逗号隔开, 冒号右边的是返回值
不需要再写return, lambda语句构建的其实是一个函数对象
格式: g = lambda x, y: x * y
调用: g (2,4)
---------------------------
第四节:
switch语句的实现 (python本身不提供switch)
a.通过字典调用函数
形式: {1: case1,2: case2}.get (x, lambda * arg, * * key) ()
例: from _ _ future _ _ import division
def jia (x, y):
return x + y
def jian (x, y):
return x - y
def cheng (x, y):
return x * y
def chu (x, y):
return x / y
operator = {+: jia, : jian,
“*”:程,“/”:楚}
您可能关注的文档
- 2011年幼儿园学期末工作总结(Summary of work at the end of the kindergarten semester in 2011).doc
- 2011年护士资格考试精品试题精选(In 2011, the nurse qualification examination questions were selected).doc
- 2011年普通高等学校招生统一考试(广东卷)理综卷文档版(无答案)(2011 college entrance examination (Guangdong volume) comprehensive volume document version (no answer)).doc
- 2011年湖南省职中对口考试大纲——英语(2011 Hunan Province vocational counterparts -- English Syllabus).doc
- 2011年福建高考文综答案(2011 Fujian college entrance examination comprehensive answer).doc
- 2011年考研英语翻译备考高分建议(2011 exams for postgraduate studies).doc
- 2011年考研辅导心理学测试题(2011 postgraduate exams psychological tests).doc
- 2011年征地拆迁补偿暂行条例(Provisional Regulations on compensation for land expropriation and demolition in 2011).doc
- 2011年高中语文成语和熟语易错专题练习(On 2011 Chinese idioms and sayings fallible exercises).doc
- 2011年高考福建文综卷 历史部分)(2011 college entrance examination, Fujian comprehensive history section).doc
- qq相册(QQ album).doc
- qsi-016_进料检验规范(Qsi-016_ feed inspection specification).doc
- qq餐厅菜(QQ restaurant food).doc
- redhat linux下vi vim 的使用快捷键(RedHat Linux under VI VIM using the shortcut key).doc
- redhat as4下的apache svn的ldap认证详解(RedHat AS4 under Apache SVN LDAP authentication detailed).doc
- redhat4安装oracle10g的参数设置(Redhat4 installs the parameter settings for Oracle10g).doc
- representational state transfer表述性状态转移(表述性状态转移表述性状态转移).doc
- requirements for installing oracle 9ir2 on rhel 4 [id 303859.1](安装Oracle在9iR2 RHEL 4上[要求]编号303859.1).doc
- [2min]恋上你指尖的温柔([2min] love the gentle touch of your fingertips).doc
- [人教版]新目标英语八年级上册知识要点([PEP] new target English grade eight points of knowledge).doc
文档评论(0)