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. linux串口基本编程

    Linux的串口表现为设备文件.Linux的串口设备文件命名一般为/dev/ttySn(n=0.1.2„„),若串口是USB扩展的,则串口设备文件命名多为/dev/ttyUSBn(n=0.1.2„„) ...

  2. 【转】Jquery修改image的src属性,图片不加载问题

    1.当点击某一按钮的时候,把图片域中的图片改变一下    <img id="randimg" src="/servlet/CreateValidateNum&quo ...

  3. linux uid/euid/suid

    Each UNIX process has 3 UIDs associated to it. Superuser/root is UID=0. UID Read UID. It is of the u ...

  4. Dev控件GridControl实现CheckBox列和ComBox列

    1.在sql语句中添加空白行,如select c1,c2 null c3 from xxx; 2.将sql语句查询结果与gdc绑定CmmFrm.BestFitGridViewColumnsWidth( ...

  5. Matlab并行编程方法1

    相信很多朋友在利用matlab进行计算时,会遇到循环次数过大,或者是单次计算量过大的问题,比如需要计算的数值阵列数据量过大,利用传统的编程方式,跑一次程序几个小时,都要等的急死了是不是呢?如果遇到这种 ...

  6. openGL一些概念01

    顶点数据: 顶点数据是一系列顶点的集合. 一个顶点(Vertex)是一个3d坐标的数据的集合. 而顶点数据是用顶点属性(Vertex Attribute)表示的,它可以包含任何我们想用的数据. (但是 ...

  7. 『原』在Linux下反编译Android .apk文件 使用apktool dex2jar JD-eclipse

    一.使用apktool 将 apk反编译生成程序的源代码和图片.XML配置.语言资源等文件 具体步骤: (1)下载反编译工具包:apktool 官方的打不开 http://apktool.shouji ...

  8. SQL Server连接Oracle FAIL

    第一步 安装好oracle客户端Oracle 11.2.0.3 Client Win 64-bit,并配置好TNS信息 第二步,配置odbc信息 配置好odbc连接信息,sql server肯定不能直 ...

  9. day17-jdbc 6.Connection介绍

    package cn.itcast.jdbc; import com.mysql.jdbc.Connection; import java.sql.DriverManager; import java ...

  10. JavaScript中的匿名函数及函数的闭包(转)

    JavaScript中的匿名函数及函数的闭包  https://www.cnblogs.com/wl0000-03/p/6050108.html 1.匿名函数 函数是JavaScript中最灵活的一种 ...