美文网首页
学习笔记系列——基础知识(三)

学习笔记系列——基础知识(三)

作者: 升华的信石 | 来源:发表于2017-09-17 16:24 被阅读2次

    人生苦短,我用python

    高级特性:

    切片(slice):  list[0:n]  list[-2:]--倒数切片

    list[:10:6]----前十个数每六个取一个

    可用于字符串、元组、列表


    迭代:for---in

    字典的迭代:for key in dict(): 默认情况下,dict迭代的是key

    for value in dict.values()  迭代value

    for k,v in dict.items():    同时迭代

    判断是否可迭代:from collections import Iterable

    isinstance(,Iterable)

    enumerate 函数:for i,value in enumerate([])-----迭代索引-元素对


    列表生成式:[元素 for x in range() if 条件:]

    [m + n for m in 'ABC' for n in 'XYZ'] 生成全排列

    [k + '=' + v for k,v in dict.items()] 生成两个变量的list

    [s.lower() for s in list()]  使用函数

    使用if isinstance(s,类型)判断是否为需要迭代(Iterable)的类型


    生成器(generator):将列表生成式的 [ ] 改为()

    调用函数时返回一个generator对象而非值,需使用for或while循环

    StopIteration 退出循环

    迭代器(Iterator):被next()函数调用并不断返回下一个值的对象称为迭代器

    可迭代对象Iterable:list、tuple、dict、set、str

    迭代器:通过iter()函数调用list\dict\str

    数据流-----惰性计算的序列

    来自百度

    too tired

    The second day that i have learned python with data manipulation.

    However,I aslo feel pleased and satisfied during the two substantial days.

    Life is short,we need programming to help us not only at work but at daily lives.

    Although,the professioon which i wish to have is not the programmer or data enginer but the registration Specialist for medicine.

    I just want to spend so much time learning it .We can find lot's of courses free on the Internet.You just need adding them in your list and taking in it.

    I will make records during the time that i have learned python with all of you.

    共勉

    相关文章

      网友评论

          本文标题:学习笔记系列——基础知识(三)

          本文链接:https://www.haomeiwen.com/subject/onxmsxtx.html