1、import this  Python之禅,圣经。

>>> import this
The Zen of Python, by Tim Peters Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

2、title()  使字符串第一个字母大写

>>> s = "cairui"
>>> print(s.title())
Cairui

3、列表的负索引

-1代表最后一个元素,-2代表倒数第二元素

>>> s = ['cairui',123,456,789,'lei']
>>> print(s[-1])
lei
>>> print(s[-2])
789
>>>

4、range

>>> range(1,5)
[1, 2, 3, 4]
>>> numbers = list(range(1,5))
>>> print(numbers)
[1, 2, 3, 4]
>>>
>>> i1 = list(range(2,11,2))
>>> print i1
[2, 4, 6, 8, 10]

5、min(列表)  取最小值  max(列表) 取最大值  sum(列表) 求和

6.用切片打印整个列表

>>> players = [1,2,3,4,5]
>>> print(players[:])
[1, 2, 3, 4, 5]
>>>

  

7、append  在列表末尾添加元素  insert(索引,内容)在第几个索引位置添加元素  

>>> s = ['a',123,456,789]
>>> s.append('rui')
>>> print(s)
['a', 123, 456, 789, 'rui']

['a', 123, 456, 789, 'rui'] >>> s.insert(0,'rui') >>> print(s) ['rui', 'a', 123, 456, 789, 'rui'] >>>

Python列表知识补充的更多相关文章

  1. python列表解析补充:

    python列表解析补充: # 补充: f = [x + y for x in 'ABCDE' for y in '1234567'] print(f) test = [] for x in 'ABC ...

  2. 万恶之源 - Python基础知识补充

    编码转换 编码回顾: 1. ASCII : 最早的编码. ⾥⾯有英⽂⼤写字⺟, ⼩写字⺟, 数字, ⼀些特殊字符. 没有中⽂, 8个01代码, 8个bit, 1个byte 2. GBK: 中⽂国标码, ...

  3. Python基础知识补充(重要)-作用域、特殊语法

    Python作用域 python代码内部块如if语句内声明变量,在if代码段后在调用此变量并未报如“undefinded name"此类错误,例子如下: if 1 == 1: name = ...

  4. python基础知识补充

    set 集合 {} 无序 集合天然去重 增 : s.add s.update 迭代添加 删 : s.pop( ) 随机删除 返回删除值 s.clear( ) 清空 获取到的是 set( ) del s ...

  5. 从零开始的Python学习 知识补充sorted

    sorted()方法 sorted()可用于任何一个可迭代对象. 原型为sorted(iterable, cmp=None, key=None, reverse=False) iterable:一个可 ...

  6. python爬虫主要就是五个模块:爬虫启动入口模块,URL管理器存放已经爬虫的URL和待爬虫URL列表,html下载器,html解析器,html输出器 同时可以掌握到urllib2的使用、bs4(BeautifulSoup)页面解析器、re正则表达式、urlparse、python基础知识回顾(set集合操作)等相关内容。

    本次python爬虫百步百科,里面详细分析了爬虫的步骤,对每一步代码都有详细的注释说明,可通过本案例掌握python爬虫的特点: 1.爬虫调度入口(crawler_main.py) # coding: ...

  7. Python学习---django知识补充之CBV

    Django知识补充之CBV Django: url    -->  def函数      FBV[function based view]  用函数和URL进行匹配 url    --> ...

  8. python基础知识-04-字符串列表元组

    python其他知识目录 内存,cpu,硬盘,解释器 实时翻译 编译器 :一次性翻译python2,3 除法,2不能得小数,3能得小数 1.字符串操作 1.1字符串操作startswith start ...

  9. python基础知识(七)---数据类型补充、"雷区"、编码

    数据类型补充."雷区".编码 1.数据类型补充 str: #字符串数据类型补充 s1=str(123) #常用于类型转换 print(s1) #capitalize()首字母大写 ...

随机推荐

  1. install命令和cp命令的区别

    基本上,在Makefile里会用到install,其他地方会用cp命令. 它们完成同样的任务——拷贝文件,它们之间的区别主要如下: 1.最重要的一点,如果目标文件存在,cp会先清空文件后往里写入新文件 ...

  2. HeapCreate深入研究

    本机:win7(x86),4G内存 #include"stdafx.h"#include<windows.h>#include<stdio.h>#inclu ...

  3. jsp与struts的区别

    JSP通常用于MVC的View层,Struts1,Struts2用于MVC的Control层. JSP用来展示页面信息,使用servlet API封装而成,代替servlet中response向客户端 ...

  4. C# WinForm 关闭登陆窗体后进程还再内存怎么办?

    问题:我们通常再制作WinForm应用程序的时候,运行程序的第一个窗口一般是登陆窗口.代码如下: 那么这种方式有一个弊端,这种启动方式,其实就是把登陆窗口设置为主窗体.因此,再登陆后,我们通常是调用H ...

  5. [Python Study Notes]pynput实现对键盘控制与监控

    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ...

  6. poj1753-Flip Game 【状态压缩+bfs】

    http://poj.org/problem?id=1753 Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions ...

  7. JS/jQuery--iframe框架内外元素的操作(转)

    JS/jQuery--iframe框架内外元素的操作 原创 2017年12月07日 14:23:09 标签: js / iframe 28 两个问题: 如何在父页面操作iframe框架内的元素? 如何 ...

  8. UWP蓝牙的例子

    https://answers.microsoft.com/zh-hans/windows/forum/windows_10-networking/%e5%9c%a8win10%e7%8e%af%e5 ...

  9. uniqid() 函数 和 microtime()函数

    uniqid() 函数基于以微秒计的当前时间,生成一个唯一的 ID.语法 uniqid(prefix,more_entropy) 参数     描述prefix     可选.为 ID 规定前缀.如果 ...

  10. 前端学习笔记2017.6.21-引入JS文件的方法

    通过网络引入JS文件 <script src="https://www.xxx.com/aaa.js"></script> 如果是引入本地JS文件 < ...