python Function

Python 2.7.10 (default, Oct 14 2015, 16:09:02)
[GCC 5.2.1 20151010] on linux2
Type "copyright", "credits" or "license()" for more information.
>>> help(list)
Help on class list in module __builtin__:

class list(object)
 |  list() -> new empty list
 |  list(iterable) -> new list initialized from iterable‘s items
 |
 |  Methods defined here:
 |
 |  __add__(...)
 |      x.__add__(y) <==> x+y
 |
 |  __contains__(...)
 |      x.__contains__(y) <==> y in x
 |
 |  __delitem__(...)
 |      x.__delitem__(y) <==> del x[y]
 |
 |  __delslice__(...)
 |      x.__delslice__(i, j) <==> del x[i:j]
 |
 |      Use of negative indices is not supported.
 |
 |  __eq__(...)
 |      x.__eq__(y) <==> x==y
 |
 |  __ge__(...)
 |      x.__ge__(y) <==> x>=y
 |
 |  __getattribute__(...)
 |      x.__getattribute__(‘name‘) <==> x.name
 |
 |  __getitem__(...)
 |      x.__getitem__(y) <==> x[y]
 |
 |  __getslice__(...)
 |      x.__getslice__(i, j) <==> x[i:j]
 |
 |      Use of negative indices is not supported.
 |
 |  __gt__(...)
 |      x.__gt__(y) <==> x>y
 |
 |  __iadd__(...)
 |      x.__iadd__(y) <==> x+=y
 |
 |  __imul__(...)
 |      x.__imul__(y) <==> x*=y
 |
 |  __init__(...)
 |      x.__init__(...) initializes x; see help(type(x)) for signature
 |
 |  __iter__(...)
 |      x.__iter__() <==> iter(x)
 |
 |  __le__(...)
 |      x.__le__(y) <==> x<=y
 |
 |  __len__(...)
 |      x.__len__() <==> len(x)
 |
 |  __lt__(...)
 |      x.__lt__(y) <==> x<y
 |
 |  __mul__(...)
 |      x.__mul__(n) <==> x*n
 |
 |  __ne__(...)
 |      x.__ne__(y) <==> x!=y
 |
 |  __repr__(...)
 |      x.__repr__() <==> repr(x)
 |
 |  __reversed__(...)
 |      L.__reversed__() -- return a reverse iterator over the list
 |
 |  __rmul__(...)
 |      x.__rmul__(n) <==> n*x
 |
 |  __setitem__(...)
 |      x.__setitem__(i, y) <==> x[i]=y
 |
 |  __setslice__(...)
 |      x.__setslice__(i, j, y) <==> x[i:j]=y
 |
 |      Use  of negative indices is not supported.
 |
 |  __sizeof__(...)
 |      L.__sizeof__() -- size of L in memory, in bytes
 |
 |  append(...)
 |      L.append(object) -- append object to end
 |
 |  count(...)
 |      L.count(value) -> integer -- return number of occurrences of value
 |
 |  extend(...)
 |      L.extend(iterable) -- extend list by appending elements from the iterable
 |
 |  index(...)
 |      L.index(value, [start, [stop]]) -> integer -- return first index of value.
 |      Raises ValueError if the value is not present.
 |
 |  insert(...)
 |      L.insert(index, object) -- insert object before index
 |
 |  pop(...)
 |      L.pop([index]) -> item -- remove and return item at index (default last).
 |      Raises IndexError if list is empty or index is out of range.
 |
 |  remove(...)
 |      L.remove(value) -- remove first occurrence of value.
 |      Raises ValueError if the value is not present.
 |
 |  reverse(...)
 |      L.reverse() -- reverse *IN PLACE*
 |
 |  sort(...)
 |      L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*;
 |      cmp(x, y) -> -1, 0, 1
 |
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |
 |  __hash__ = None
 |
 |  __new__ = <built-in method __new__ of type object>
 |      T.__new__(S, ...) -> a new object with type S, a subtype of T

>>> a=‘nihao‘
>>> a
‘nihao‘
>>> a=list(a)
>>> a
[‘n‘, ‘i‘, ‘h‘, ‘a‘, ‘o‘]
>>> max(1,2,3,7,6,5)
7
>>> num=[1,2,3,4,]
>>> len(num)
4
>>> max(num)
4
>>> min(num)
1
>>> a=(1,2,3,4,5)
>>> type(a)
<type ‘tuple‘>
>>> max(a)
5
>>> min(a)
1
>>> str="123456780"
>>> min(str)
‘0‘
>>> max(str)
‘8‘
>>> str=‘23eras‘
>>> max(str)
‘s‘
>>> min(str)
‘2‘
>>>
>>>
>>>
>>>
>>> num=[1,2,3,4]
>>> max=num[0]
>>> for each in num:
    if each>max:
        max=each

>>> max
4
>>> sum(num)
10
>>> sum(num,1)
11
>>> enumerate(num)
<enumerate object at 0xb53fc784>
>>> list(enumerate(num))
[(0, 1), (1, 2), (2, 3), (3, 4)]
>>> zip(num)
[(1,), (2,), (3,), (4,)]
>>> a=[5,6,7]
>>> zip(num,a)
[(1, 5), (2, 6), (3, 7)]
>>> sorted(num)
[1, 2, 3, 4]
>>> reversed(num)
<listreverseiterator object at 0xb53edb8c>
>>> list(reversed(num))
[4, 3, 2, 1]
>>> 
时间: 2024-10-10 00:25:08

python Function的相关文章

Python Function Note

Python Function Note 1 #汉诺塔问题Python实现 2 def my_move(n, a, b, c): 3 if n == 1: 4 print(a + ' --> ' + c) 5 else: 6 my_move(n-1, a, c, b)#将前n-1个盘子从a放到b 7 my_move(1, a, b, c)#将最下面的盘子从a放到c 8 my_move(n-1, b, a, c)#将b上的n-1个盘子放到c上 9 return 1 #杨辉三角Python实现 2

跟着文档学python(三):zip (Python function, in 2. Built-in Functions)

一,函数的文档: zip(): zip(*iterables) Make an iterator that aggregates elements from each of the iterables. Returns an iterator of tuples, where the i-th tuple contains the i-th element from each of the argument sequences or iterables. The iterator stops w

Python自动化运维课程学习--Day3

本文为参加老男孩Python自动化运维课程第三天学习内容的总结. 大致内容如下: 1.文件操作 2.字符编码转码相关操作 3.函数 0.关于本文中所有运行Python代码的环境: --操作系统:Ubuntu 16.10 (Linux 4.8.0) --Python版本:3.5.2 python2.7.12 --Python IDE: PyCharm 2016.3.2 一.文件操作: 1.文件操作流程:以只读.写(覆盖写).追加写.读写.追加读写.二进制读写等模式打开文件 ==> 得到文件句柄,并

Python黑客编程ARP欺骗

Python灰帽编程 3.1 ARP欺骗 ARP欺骗是一种在局域网中常用的攻击手段,目的是让局域网中指定的(或全部)的目标机器的数据包都通过攻击者主机进行转发,是实现中间人攻击的常用手段,从而实现数据监听.篡改.重放.钓鱼等攻击方式. 在进行ARP欺骗的编码实验之前,我们有必要了解下ARP和ARP欺骗的原理. 3.1.1 ARP和ARP欺骗原理 ARP是地址转换协议(Address Resolution Protocol)的英文缩写,它是一个链路层协议,工作在OSI 模型的第二层,在本层和硬件接

Python黑客编程基础3网络数据监听和过滤

Python黑客编程3网络数据监听和过滤 课程的实验环境如下: •      操作系统:kali Linux 2.0 •      编程工具:Wing IDE •      Python版本:2.7.9 •      涉及到的主要python模块:pypcap,dpkt,scapy,scapy-http 涉及到的几个python网络抓包和分析的模块,dpkt和scapy在kali linux 2.0 中默认已经被安装,如果你的系统中没有需要手动安装一下,下面是软件包安装的简单说明. 在kali下

python closures and decorators

Functions as objects and closures python中的函数是first-class objects,即它们可以作为参数传递到其他函数中,可以存储到数据结构中,也可以作为函数的返回值 一个简单例子 # foo.py def callf(func): return func() >>> import foo >>> def hello(): ... return 'hello' ... >>> f = foo.callf(he

全面Python小抄(转)

add by zhj: 有些地方不正确,有时间再改吧 原文:Python Cheat Sheet Cheat sheet of Python. Some basic concepts for Python programmer need to know. Python Naming Styles # see: PEP8 # for public use var # for internal use _var # convention to avoid conflict keyword var_

python自学笔记

python自学笔记 python自学笔记 1.输出 2.输入 3.零碎 4.数据结构 4.1 list 类比于java中的数组 4.2 tuple 元祖 5.条件判断和循环 5.1 条件判断 5.2 循环 6.使用dict和set 6.1 dict 6.2 set 7.函数的使用 7.1函数返回多个值,同时接受多个值 7.2函数参数的默认值 7.3可变参数的函数 7.4可变个数带参数名的入参 7.5参数类型组合 8.关于函数递归 9.python的高级特性 9.1切片 9.2遍历 9.3列表生

Python语言笔记

Python是一种解释性(没有编译).交互式.面向对象的语言 1.安装python编译器 版本:Python2.7比较普遍,Python不是向下兼容的软件,因此Python3.x有些东西不好找资料 2.在 Windows 设置环境变量,在命令提示框中(cmd) : 输入 path %path%;C:\Python , 按下"Enter".在环境变量中添加Python目录(注意: C:\Python 是Python的安装目录.) 3.输入ctrl+z再按Enter键退出Python编译器