Python学习第二天

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python学习第二天相关的知识,希望对你有一定的参考价值。

基本数据类型

         Python中一切事物都是对象,对象基于类创建

编码:

         Ascii  8位共256个字符

         Unicode码,至少16位

         Utf-8 如果是数字、字母、字符2个字节,16位来存;汉字用3个字节,24位来存。

转码:

  

技术分享


Python内部提供一个sys模块,其中sys.argv用来捕获执行Python脚本传入的参数

#!usr/bin/env python3import sysprint(sys.argv)

F:\py>python improt_argv.py 8000[‘improt_argv.py‘, ‘8000‘]

字符串拼接:

         Python中的字符串在C语言中体现为一个字数组,每次创建字符串需要在内存中开辟一块连续的空,并且一旦需要修改字符串的话,就需要再次开辟空间,使用“+”号拼接在内存中会重新开辟一块空间,称为万恶的“+”号。

  字符串格式化:#python学习第一天中有提到。

  字符串常用操作:

         移除空白: strip

         分割: split

         长度:len

         索引:a[1]

         切片:a[0:]  a[:5]  a[1:3:2]

列表:

列表常用方法:

         索引:index

         切片:a[0:]  a[:5]  a[1:3:2]

         追加:append

         删除:remove del pop

         长度:len

         循环:for while  (foreach#其他语言)

         循环中断:break;contiune;pass;return;exit

         包含:in (__contains__和in等同)

元组:#元组的元素不可修改,元组的元素的元素可被修改

         >>> t = (1,2,{"k":"v"})

         >>> t[2]["k"] = 45#元组的元素的元素可被修改

         >>> print(t)

         (1, 2, {‘k‘: 45})

字典:

         索引: key

         新增: a[key]= xx

         删除: del a[key]

         键、值、键值对

         Keys  values  items

         循环:for

         长度:len


整型:

class int(object):    """

    int(x=0) -> integer
   int(x, base=10) -> integer
   
   Convert a number or string to an integer, or return 0 if no arguments
   are given.  If x is a number, return x.__int__().  For floating point
   numbers, this truncates towards zero.
   
   If x is not a number or if base is given, then x must be a string,
   bytes, or bytearray instance representing an integer literal in the
   given base.  The literal can be preceded by ‘+‘ or ‘-‘ and be surrounded
   by whitespace.  The base defaults to 10.  Valid bases are 0 and 2-36.
   Base 0 means to interpret the base from the string as an integer literal.
   >>> int(‘0b100‘, base=0)
   4    """def bit_length(self): # real signature unknown; restored from __doc__#返回该数字二进制位占用的最少位数"""
   int.bit_length() -> int

   Number of bits necessary to represent self in binary.
>>> bin(37)
   ‘0b100101‘
>>> (37).bit_length()    
"""return 0def conjugate(self, *args, **kwargs): # real signature unknown""" Returns self, the complex conjugate of any int. """#返回该复数的共轭复数passdef from_bytes(cls, bytes, byteorder, *args, **kwargs): # real signature unknown; NOTE: unreliably restored from __doc__ """
   int.from_bytes(bytes, byteorder, *, signed=False) -> int

   Return the integer represented by the given array of bytes.

   The bytes argument must be a bytes-like object (e.g. bytes or bytearray).

   The byteorder argument determines the byte order used to represent the
   integer.  If byteorder is ‘big‘, the most significant byte is at the
   beginning of the byte array.  If byteorder is ‘little‘, the most
   significant byte is at the end of the byte array.  To request the native
   byte order of the host system, use `sys.byteorder‘ as the byte order value.

   The signed keyword-only argument indicates whether two‘s complement is
   used to represent the integer."""passdef to_bytes(self, length, byteorder, *args, **kwargs): # real signature unknown; NOTE: unreliably restored from __doc__ """
   int.to_bytes(length, byteorder, *, signed=False) -> bytes

   Return an array of bytes representing an integer.

   The integer is represented using length bytes.  An OverflowError is
   raised if the integer is not representable with the given number of
   bytes.

   The byteorder argument determines the byte order used to represent the
   integer.  If byteorder is ‘big‘, the most significant byte is at the
   beginning of the byte array.  If byteorder is ‘little‘, the most
   significant byte is at the end of the byte array.  To request the native
   byte order of the host system, use `sys.byteorder‘ as the byte order value.

   The signed keyword-only argument determines whether two‘s complement is
   used to represent the integer.  If signed is False and a negative integer
   is given, an OverflowError is raised."""passdef __abs__(self, *args, **kwargs): # real signature unknown""" abs(self) """#返回绝对值passdef __add__(self, *args, **kwargs): # real signature unknown""" Return self+value. """#加法运算passdef __and__(self, *args, **kwargs): # real signature unknown""" Return self&value. """#与运算passdef __bool__(self, *args, **kwargs): # real signature unknown""" self != 0 """#返回bool值passdef __ceil__(self, *args, **kwargs): # real signature unknown""" Ceiling of an Integral returns itself. """#定义空函数passdef __divmod__(self, *args, **kwargs): # real signature unknown""" Return divmod(self, value). """#相除,得到商和余数组成的元组(用于网页分页)>>> all_item = 95
>>> pager = 10
>>> all_item.__divmod__(pager)
(9, 5)passdef __eq__(self, *args, **kwargs): # real signature unknown""" Return self==value. """#判断两值是否相等passdef __float__(self, *args, **kwargs): # real signature unknown""" float(self) """#浮点型passdef __floordiv__(self, *args, **kwargs): # real signature unknown""" Return self//value. """#地板除passdef __floor__(self, *args, **kwargs): # real signature unknown""" Flooring an Integral returns itself. """#passdef __format__(self, *args, **kwargs): # real signature unknownpassdef __getattribute__(self, *args, **kwargs): # real signature unknown""" Return getattr(self, name). """passdef __getnewargs__(self, *args, **kwargs): # real signature unknownpassdef __ge__(self, *args, **kwargs): # real signature unknown""" Return self>=value. """#大于等于passdef __gt__(self, *args, **kwargs): # real signature unknown""" Return self>value. """#大于passdef __hash__(self, *args, **kwargs): # real signature unknown""" Return hash(self). """#哈希passdef __index__(self, *args, **kwargs): # real signature unknown""" Return self converted to an integer, if self is suitable for use as an index into a list. """#索引passdef __init__(self, x, base=10): # known special case of int.__init__#构造方法"""
   int(x=0) -> integer
   int(x, base=10) -> integer

   Convert a number or string to an integer, or return 0 if no arguments
   are given.  If x is a number, return x.__int__().  For floating point
   numbers, this truncates towards zero.

   If x is not a number or if base is given, then x must be a string,
   bytes, or bytearray instance representing an integer literal in the
   given base.  The literal can be preceded by ‘+‘ or ‘-‘ and be surrounded
   by whitespace.  The base defaults to 10.  Valid bases are 0 and 2-36.
   Base 0 means to interpret the base from the string as an integer literal.
>>> int(‘0b100‘, base=0)
   4
   # (copied from class doc)"""passdef __int__(self, *args, **kwargs): # real signature unknown""" int(self) """#整型passdef __invert__(self, *args, **kwargs): # real signature unknown""" ~self """#位运算passdef __le__(self, *args, **kwargs): # real signature unknown""" Return self<=value. """#小于等于passdef __lshift__(self, *args, **kwargs): # real signature unknown""" Return self<<value. """#左移passdef __lt__(self, *args, **kwargs): # real signature unknown""" Return self<value. """#小于passdef __mod__(self, *args, **kwargs): # real signature unknown""" Return self%value. """#取模passdef __mul__(self, *args, **kwargs): # real signature unknown""" Return self*value. """#除以passdef __neg__(self, *args, **kwargs): # real signature unknown""" -self """#负号[email protected] # known case of __new__def __new__(*args, **kwargs): # real signature unknown""" Create and return a new object.  See help(type) for accurate signature. """passdef __ne__(self, *args, **kwargs): # real signature unknown""" Return self!=value. """#不等于passdef __or__(self, *args, **kwargs): # real signature unknown""" Return self|value. """#或passdef __pos__(self, *args, **kwargs): # real signature unknown""" +self """#加号passdef __pow__(self, *args, **kwargs): # real signature unknown""" Return pow(self, value, mod). """#次方(**)passdef __radd__(self, *args, **kwargs): # real signature unknown""" Return value+self. """#加法,右边的值移到左边passdef __rand__(self, *args, **kwargs): # real signature unknown""" Return value&self. """#与运算,右边的值移到左边passdef __rdivmod__(self, *args, **kwargs): # real signature unknown""" Return divmod(value, self). """#相除,得到商和余数组成的元组(用于网页分页)右边的值移到左边passdef __repr__(self, *args, **kwargs): # real signature unknown""" Return repr(self). """passdef __rfloordiv__(self, *args, **kwargs): # real signature unknown""" Return value//self. """#地板除,右边的值移到左边passdef __rlshift__(self, *args, **kwargs): # real signature unknown""" Return value<<self. """#左移,右边的值移到左边passdef __rmod__(self, *args, **kwargs): # real signature unknown""" Return value%self. """#除法,右边的值移到左边passdef __rmul__(self, *args, **kwargs): # real signature unknown""" Return value*self. """#乘法,右边的值移到左边passdef __ror__(self, *args, **kwargs): # real signature unknown""" Return value|self. """#或,右边的值移到左边passdef __round__(self, *args, **kwargs): # real signature unknown"""
   Rounding an Integral returns itself.
   Rounding with an ndigits argument also returns an integer."""passdef __rpow__(self, *args, **kwargs): # real signature unknown""" Return pow(value, self, mod). """passdef __rrshift__(self, *args, **kwargs): # real signature unknown""" Return value>>self. """passdef __rshift__(self, *args, **kwargs): # real signature unknown""" Return self>>value. """passdef __rsub__(self, *args, **kwargs): # real signature unknown""" Return value-self. """passdef __rtruediv__(self, *args, **kwargs): # real signature unknown""" Return value/self. """passdef __rxor__(self, *args, **kwargs): # real signature unknown""" Return value^self. """passdef __sizeof__(self, *args, **kwargs): # real signature unknown""" Returns size in memory, in bytes """passdef __str__(self, *args, **kwargs): # real signature unknown""" Return str(self). """passdef __sub__(self, *args, **kwargs): # real signature unknown""" Return self-value. """passdef __truediv__(self, *args, **kwargs): # real signature unknown""" Return self/value. """passdef __trunc__(self, *args, **kwargs): # real signature unknown""" Truncating an Integral returns itself. """passdef __xor__(self, *args, **kwargs): # real signature unknown""" Return self^value. """pass 


字符串:

class str(object):"""
    str(object=‘‘) -> str
   str(bytes_or_buffer[, encoding[, errors]]) -> str

   Create a new string object from the given object. If encoding or
   errors is specified, then the object must expose a data buffer
   that will be decoded using the given encoding and error handler.
   Otherwise, returns the result of object.__str__() (if defined)
   or repr(object).
   encoding defaults to sys.getdefaultencoding().
   errors defaults to ‘strict‘."""def capitalize(self): # real signature unknown; restored from __doc__#首字母转为大写"""
       S.capitalize() -> str

       Return a capitalized version of S, i.e. make the first character
       have upper case and the rest lower case."""return ""def casefold(self): # real signature unknown; restored from __doc__#转为小写"""
       S.casefold() -> str

       Return a version of S suitable for caseless comparisons."""return ""def center(self, width, fillchar=None): # real signature unknown; restored from __doc__#居中  
>>> name.center(20,‘*‘)‘********eric********‘"""
       S.center(width[, fillchar]) -> str

       Return S centered in a string of length width. Padding is
       done using the specified fill character (default is a space)"""return ""def count(self, sub, start=None, end=None): # real signature unknown; restored from __doc__#计算出现的次数,start和end参数表示范围,可选>>> name = ‘fsfgdfgdfsfgdfgf‘>>> name.count(‘f‘,0,10)4"""
       S.count(sub[, start[, end]]) -> int

       Return the number of non-overlapping occurrences of substring sub in
       string S[start:end].  Optional arguments start and end are
       interpreted as in slice notation."""return 0def encode(self, encoding=‘utf-8‘, errors=‘strict‘): # real signature unknown; restored from __doc__#编码>>> name = "李杰">>> name.encode(‘gbk‘)
b‘\xc0\xee\xbd\xdc‘"""
       S.encode(encoding=‘utf-8‘, errors=‘strict‘) -> bytes

       Encode S using the codec registered for encoding. Default encoding
       is ‘utf-8‘. errors may be given to set a different error
       handling scheme. Default is ‘strict‘ meaning that encoding errors raise
       a UnicodeEncodeError. Other possible values are ‘ignore‘, ‘replace‘ and
       ‘xmlcharrefreplace‘ as well as any other name registered with
       codecs.register_error that can handle UnicodeEncodeErrors."""return b""def endswith(self, suffix, start=None, end=None): # real signature unknown; restored from __doc__#判断以什么结尾>>> name = "alex">>> name.endswith("x",0,5)
True"""
       S.endswith(suffix[, start[, end]]) -> bool

       Return True if S ends with the specified suffix, False otherwise.
       With optional start, test S beginning at that position.
       With optional end, stop comparing S at that position.
       suffix can also be a tuple of strings to try."""return False    def expandtabs(self, tabsize=8): # real signature unknown; restored from __doc__#把TAB转为空格(默认为8个空格)>>> name = "a\tlex">>> name.expandtabs()‘a       lex‘"""
       S.expandtabs(tabsize=8) -> str

       Return a copy of S where all tab characters are expanded using spaces.
       If tabsize is not given, a tab size of 8 characters is assumed."""return ""def find(self, sub, start=None, end=None): # real signature unknown; restored from __doc__#检测字符串,有则返回索引位置,没有则返回-1."""
       S.find(sub[, start[, end]]) -> int

       Return the lowest index in S where substring sub is found,
       such that sub is contained within S[start:end].  Optional
       arguments start and end are interpreted as in slice notation.

       Return -1 on failure."""return 0def format(*args, **kwargs): # known special case of str.format"""#字符串格式化
       S.format(*args, **kwargs) -> str

       Return a formatted version of S, using substitutions from args and kwargs.
       The substitutions are identified by braces (‘{‘ and ‘}‘)."""pass

   def format_map(self, mapping): # real signature unknown; restored from __doc__"""
       S.format_map(mapping) -> str

       Return a formatted version of S, using substitutions from mapping.
       The substitutions are identified by braces (‘{‘ and ‘}‘)."""return ""def index(self, sub, start=None, end=None): # real signature unknown; restored from __doc__#检测字符串,有则返回索引位置,没有则产生一个异常"""
       S.index(sub[, start[, end]]) -> int

       Like S.find() but raise ValueError when the substring is not found."""return 0def isalnum(self): # real signature unknown; restored from __doc__"""#是否是字母或数字
       S.isalnum() -> bool

       Return True if all characters in S are alphanumeric
       and there is at least one character in S, False otherwise."""return False    def isalpha(self): # real signature unknown; restored from __doc__"""#是否是字母
       S.isalpha() -> bool

       Return True if all characters in S are alphabetic
       and there is at least one character in S, False otherwise."""return False    def isdecimal(self): # real signature unknown; restored from __doc__#是否包含十进制数字"""
       S.isdecimal() -> bool

       Return True if there are only decimal characters in S,
       False otherwise."""return False    def isdigit(self): # real signature unknown; restored from __doc__#是否包含数字"""
       S.isdigit() -> bool

       Return True if all characters in S are digits
       and there is at least one character in S, False otherwise."""return False    def isidentifier(self): # real signature unknown; restored from __doc__"""
       S.isidentifier() -> bool

       Return True if S is a valid identifier according
       to the language definition.

       Use keyword.iskeyword() to test for reserved identifiers
       such as "def" and "class"."""return False    def islower(self): # real signature unknown; restored from __doc__#是否都是小写"""
       S.islower() -> bool

       Return True if all cased characters in S are lowercase and there is
       at least one cased character in S, False otherwise."""return False    def isnumeric(self): # real signature unknown; restored from __doc__#是否是数字"""
       S.isnumeric() -> bool

       Return True if there are only numeric characters in S,
       False otherwise."""return False    def isprintable(self): # real signature unknown; restored from __doc__#是否可以打印"""
       S.isprintable() -> bool

       Return True if all characters in S are considered
       printable in repr() or S is empty, False otherwise."""return False    def isspace(self): # real signature unknown; restored from __doc__#是否是空格"""
       S.isspace() -> bool

       Return True if all characters in S are whitespace
       and there is at least one character in S, False otherwise."""return False    def istitle(self): # real signature unknown; restored from __doc__#是否是标题(所有的单词都是以大写开始,其余均小写)"""
       S.istitle() -> bool

       Return True if S is a titlecased string and there is at least one
       character in S, i.e. upper- and titlecase characters may only
       follow uncased characters and lowercase characters only cased ones.
       Return False otherwise."""return False    def isupper(self): # real signature unknown; restored from __doc__#是否都是大写"""
       S.isupper() -> bool

       Return True if all cased characters in S are uppercase and there is
       at least one cased character in S, False otherwise."""return False    def join(self, iterable): # real signature unknown; restored from __doc__#用作拼接>>> li = ["a","b","c"]>>>"_".join(li)‘a_b_c‘"""
       S.join(iterable) -> str

       Return a string which is the concatenation of the strings in the
       iterable.  The separator between elements is S."""return ""def ljust(self, width, fillchar=None): # real signature unknown; restored from __doc__#左对齐,用空格填充至长度为width的字符串"""
       S.ljust(width[, fillchar]) -> str

       Return S left-justified in a Unicode string of length width. Padding is
       done using the specified fill character (default is a space)."""return ""def lower(self): # real signature unknown; restored from __doc__#转换字符中所有大写字符为小写"""
       S.lower() -> str

       Return a copy of the string S converted to lowercase."""return ""def lstrip(self, chars=None): # real signature unknown; restored from __doc__#去掉字符串左边的所有的空格"""
       S.lstrip([chars]) -> str

       Return a copy of the string S with leading whitespace removed.
       If chars is given and not None, remove characters in chars instead."""return ""def maketrans(self, *args, **kwargs): # real signature unknown"""
       Return a translation table usable for str.translate().

       If there is only one argument, it must be a dictionary mapping Unicode
       ordinals (integers) or characters to Unicode ordinals, strings or None.
       Character keys will be then converted to ordinals.
       If there are two arguments, they must be strings of equal length, and
       in the resulting dictionary, each character in x will be mapped to the
       character at the same position in y. If there is a third argument, it
       must be a string, whose characters will be mapped to None in the result."""pass

   def partition(self, sep): # real signature unknown; restored from __doc__#分割成三部分>>> name = "alexisdawang">>> name.partition("is")
(‘alex‘, ‘is‘, ‘dawang‘)"""
       S.partition(sep) -> (head, sep, tail)

       Search for the separator sep in S, and return the part before it,
       the separator itself, and the part after it.  If the separator is not
       found, return S and two empty strings."""pass

   def replace(self, old, new, count=None): # real signature unknown; restored from __doc__#替换>>> name.replace("wang","she").partition("is")
(‘alex‘, ‘is‘, ‘dashe‘)"""
       S.replace(old, new[, count]) -> str

       Return a copy of S with all occurrences of substring
       old replaced by new.  If the optional argument count is
       given, only the first count occurrences are replaced."""return ""def rfind(self, sub, start=None, end=None): # real signature unknown; restored from __doc__#从右向左检测,有则返回索引位置,没有则返回-1."""
       S.rfind(sub[, start[, end]]) -> int

       Return the highest index in S where substring sub is found,
       such that sub is contained within S[start:end].  Optional
       arguments start and end are interpreted as in slice notation.

       Return -1 on failure."""return 0def rindex(self, sub, start=None, end=None): # real signature unknown; restored from __doc__#从右向左检测"""
       S.rindex(sub[, start[, end]]) -> int

       Like S.rfind() but raise ValueError when the substring is not found."""return 0def rjust(self, width, fillchar=None): # real signature unknown; restored from __doc__#从右向左检测"""
       S.rjust(width[, fillchar]) -> str

       Return S right-justified in a string of length width. Padding is
       done using the specified fill character (default is a space)."""return ""def rpartition(self, sep): # real signature unknown; restored from __doc__#从右向左检测"""
       S.rpartition(sep) -> (head, sep, tail)

       Search for the separator sep in S, starting at the end of S, and return
       the part before it, the separator itself, and the part after it.  If the
       separator is not found, return two empty strings and S."""pass

   def rsplit(self, sep=None, maxsplit=-1): # real signature unknown; restored from __doc__#指定字符进行分割,从右开始"""
       S.rsplit(sep=None, maxsplit=-1) -> list of strings

       Return a list of the words in S, using sep as the
       delimiter string, starting at the end of the string and
       working to the front.  If maxsplit is given, at most maxsplit
       splits are done. If sep is not specified, any whitespace string
       is a separator."""return []def rstrip(self, chars=None): # real signature unknown; restored from __doc__#移除右边空格"""
       S.rstrip([chars]) -> str

       Return a copy of the string S with trailing whitespace removed.
       If chars is given and not None, remove characters in chars instead."""return ""def split(self, sep=None, maxsplit=-1): # real signature unknown; restored from __doc__#指定字符进行分割"""
       S.split(sep=None, maxsplit=-1) -> list of strings

       Return a list of the words in S, using sep as the
       delimiter string.  If maxsplit is given, at most maxsplit
       splits are done. If sep is not specified or is None, any
       whitespace string is a separator and empty strings are
       removed from the result."""return []def splitlines(self, keepends=None): # real signature unknown; restored from __doc__#按行分割(同split(“\n”))"""
       S.splitlines([keepends]) -> list of strings

       Return a list of the lines in S, breaking at line boundaries.
       Line breaks are not included in the resulting list unless keepends
       is given and true."""return []def startswith(self, prefix, start=None, end=None): # real signature unknown; restored from __doc__#判断以什么开头"""
       S.startswith(prefix[, start[, end]]) -> bool

       Return True if S starts with the specified prefix, False otherwise.
       With optional start, test S beginning at that position.
       With optional end, stop comparing S at that position.
       prefix can also be a tuple of strings to try."""return False    def strip(self, chars=None): # real signature unknown; restored from __doc__#移除左右空格"""
       S.strip([chars]) -> str

       Return a copy of the string S with leading and trailing
       whitespace removed.
       If chars is given and not None, remove characters in chars instead."""return ""def swapcase(self): # real signature unknown; restored from __doc__#将所有大写转小写,小写转大写"""
       S.swapcase() -> str

       Return a copy of S with uppercase characters converted to lowercase
       and vice versa."""return ""def title(self): # real signature unknown; restored from __doc__#将所有首字母转大写"""
       S.title() -> str

       Return a titlecased version of S, i.e. words start with title case
       characters, all remaining cased characters have lower case."""return ""def translate(self, table): # real signature unknown; restored from __doc__"""
       S.translate(table) -> str

       Return a copy of the string S in which each character has been mapped
       through the given translation table. The table must implement
       lookup/indexing via __getitem__, for instance a dictionary or list,
       mapping Unicode ordinals to Unicode ordinals, strings, or None. If
       this operation raises LookupError, the character is left untouched.
       Characters mapped to None are deleted."""return ""def upper(self): # real signature unknown; restored from __doc__#转大写"""
       S.upper() -> str

       Return a copy of S converted to uppercase."""return ""def zfill(self, width): # real signature unknown; restored from __doc__#"""
       S.zfill(width) -> str

       Pad a numeric string S with zeros on the left, to fill a field
       of the specified width. The string S is never truncated."""return ""def __add__(self, *args, **kwargs): # real signature unknown""" Return self+value. """pass

   def __contains__(self, *args, **kwargs): # real signature unknown""" Return key in self. """#包含pass

   def __eq__(self, *args, **kwargs): # real signature unknown""" Return self==value. """#相等pass

   def __format__(self, format_spec): # real signature unknown; restored from __doc__#字符格式化"""
       S.__format__(format_spec) -> str

       Return a formatted version of S as described by format_spec."""return ""def __getattribute__(self, *args, **kwargs): # real signature unknown#反射用到""" Return getattr(self, name). """pass

   def __getitem__(self, *args, **kwargs): # real signature unknown""" Return self[key]. """pass

   def __getnewargs__(self, *args, **kwargs): # real signature unknownpass

   def __ge__(self, *args, **kwargs): # real signature unknown""" Return self>=value. """pass

   def __gt__(self, *args, **kwargs): # real signature unknown""" Return self>value. """pass

   def __hash__(self, *args, **kwargs): # real signature unknown""" Return hash(self). """pass

   def __init__(self, value=‘‘, encoding=None, errors=‘strict‘): # known special case of str.__init__"""
       str(object=‘‘) -> str
       str(bytes_or_buffer[, encoding[, errors]]) -> str

       Create a new string object from the given object. If encoding or
       errors is specified, then the object must expose a data buffer
       that will be decoded using the given encoding and error handler.
       Otherwise, returns the result of object.__str__() (if defined)
       or repr(object).
       encoding defaults to sys.getdefaultencoding().
       errors defaults to ‘strict‘.
       # (copied from class doc)"""pass

   def __iter__(self, *args, **kwargs): # real signature unknown""" Implement iter(self). """pass

   def __len__(self, *args, **kwargs): # real signature unknown""" Return len(self). """pass

   def __le__(self, *args, **kwargs): # real signature unknown""" Return self<=value. """pass

   def __lt__(self, *args, **kwargs): # real signature unknown""" Return self<value. """pass

   def __mod__(self, *args, **kwargs): # real signature unknown""" Return self%value. """pass

   def __mul__(self, *args, **kwargs): # real signature unknown""" Return self*value.n """[email protected] # known case of __new__def __new__(*args, **kwargs): # real signature unknown""" Create and return a new object.  See help(type) for accurate signature. """pass

   def __ne__(self, *args, **kwargs): # real signature unknown""" Return self!=value. """pass

   def __repr__(self, *args, **kwargs): # real signature unknown""" Return repr(self). """pass

   def __rmod__(self, *args, **kwargs): # real signature unknown""" Return value%self. """pass

   def __rmul__(self, *args, **kwargs): # real signature unknown""" Return self*value. """pass

   def __sizeof__(self): # real signature unknown; restored from __doc__""" S.__sizeof__() -> size of S in memory, in bytes """pass

   def __str__(self, *args, **kwargs): # real signature unknown""" Return str(self). """pass


列表:

class list(object):"""

    list() -> new empty list
   list(iterable) -> new list initialized from iterable‘s items"""def append(self, p_object): # real signature unknown; restored from __doc__#追加""" L.append(object) -> None -- append object to end """pass

   def clear(self): # real signature unknown; restored from __doc__#清空列表""" L.clear() -> None -- remove all items from L """pass

   def copy(self): # real signature unknown; restored from __doc__#浅拷贝""" L.copy() -> list -- a shallow copy of L """return []def count(self, value): # real signature unknown; restored from __doc__#统计元素出现次数""" L.count(value) -> integer -- return number of occurrences of value """return 0def extend(self, iterable): # real signature unknown; restored from __doc__#对原列表扩展""" L.extend(iterable) -> None -- extend list by appending elements from the iterable """pass

   def index(self, value, start=None, stop=None): # real signature unknown; restored from __doc__#索引"""
       L.index(value, [start, [stop]]) -> integer -- return first index of value.
       Raises ValueError if the value is not present."""return 0def insert(self, index, p_object): # real signature unknown; restored from __doc__#指定位置插入""" L.insert(index, object) -- insert object before index """pass

   def pop(self, index=None): # real signature unknown; restored from __doc__#删除最后一个或拿到它"""
       L.pop([index]) -> item -- remove and return item at index (default last).
       Raises IndexError if list is empty or index is out of range."""pass

   def remove(self, value): # real signature unknown; restored from __doc__#指定删除"""
       L.remove(value) -> None -- remove first occurrence of value.
       Raises ValueError if the value is not present."""pass

   def reverse(self): # real signature unknown; restored from __doc__#反转""" L.reverse() -- reverse *IN PLACE* """pass

   def sort(self, key=None, reverse=False): # real signature unknown; restored from __doc__#排序""" L.sort(key=None, reverse=False) -> None -- stable sort *IN PLACE* """pass

   def __add__(self, *args, **kwargs): # real signature unknown""" Return self+value. """pass

   def __contains__(self, *args, **kwargs): # real signature unknown""" Return key in self. """pass

   def __delitem__(self, *args, **kwargs): # real signature unknown""" Delete self[key]. """pass

   def __eq__(self, *args, **kwargs): # real signature unknown""" Return self==value. """pass

   def __getattribute__(self, *args, **kwargs): # real signature unknown""" Return getattr(self, name). """pass

   def __getitem__(self, y): # real signature unknown; restored from __doc__""" x.__getitem__(y) <==> x[y] """pass

   def __ge__(self, *args, **kwargs): # real signature unknown""" Return self>=value. """pass

   def __gt__(self, *args, **kwargs): # real signature unknown""" Return self>value. """pass

   def __iadd__(self, *args, **kwargs): # real signature unknown""" Implement self+=value. """pass

   def __imul__(self, *args, **kwargs): # real signature unknown""" Implement self*=value. """pass

   def __init__(self, seq=()): # known special case of list.__init__"""
       list() -> new empty list
       list(iterable) -> new list initialized from iterable‘s items
       # (copied from class doc)"""pass

   def __iter__(self, *args, **kwargs): # real signature unknown""" Implement iter(self). """pass

   def __len__(self, *args, **kwargs): # real signature unknown""" Return len(self). """pass

   def __le__(self, *args, **kwargs): # real signature unknown""" Return self<=value. """pass

   def __lt__(self, *args, **kwargs): # real signature unknown""" Return self<value. """pass

   def __mul__(self, *args, **kwargs): # real signature unknown""" Return self*value.n """[email protected] # known case of __new__def __new__(*args, **kwargs): # real signature unknown""" Create and return a new object.  See help(type) for accurate signature. """pass

   def __ne__(self, *args, **kwargs): # real signature unknown""" Return self!=value. """pass

   def __repr__(self, *args, **kwargs): # real signature unknown""" Return repr(self). """pass

   def __reversed__(self): # real signature unknown; restored from __doc__""" L.__reversed__() -- return a reverse iterator over the list """pass

   def __rmul__(self, *args, **kwargs): # real signature unknown""" Return self*value. """pass

   def __setitem__(self, *args, **kwargs): # real signature unknown""" Set self[key] to value. """pass

   def __sizeof__(self): # real signature unknown; restored from __doc__""" L.__sizeof__() -- size of L in memory, in bytes """pass__hash__ = None


元组:

def count(self, value): # real signature unknown; restored from __doc__#统计元素出现次数""" T.count(value) -> integer -- return number of occurrences of value """return 0def index(self, value, start=None, stop=None): # real signature unknown; restored from __doc__#索引"""
   T.index(value, [start, [stop]]) -> integer -- return first index of value.
   Raises ValueError if the value is not present."""return 0


字典:

class dict(object):"""
   dict() -> new empty dictionary
   dict(mapping) -> new dictionary initialized from a mapping object‘s
       (key, value) pairs
   dict(iterable) -> new dictionary initialized as if via:
       d = {}
       for k, v in iterable:
           d[k] = v
   dict(**kwargs) -> new dictionary initialized with the name=value pairs
       in the keyword argument list.  For example:  dict(one=1, two=2)"""def clear(self): # real signature unknown; restored from __doc__#清空所有元素""" D.clear() -> None.  Remove all items from D. """pass

   def copy(self): # real signature unknown; restored from __doc__#浅拷贝""" D.copy() -> a shallow copy of D """[email protected] # known casedef fromkeys(*args, **kwargs): # real signature unknown#定义同一值多个名字>>> dic = {"k1":"v1","k2":"v2"}>>> new_dic = dic.fromkeys(["k1","k2","k3"],123)>>> new_dic
{‘k3‘: 123, ‘k2‘: 123, ‘k1‘: 123}""" Returns a new dict with keys from iterable and values equal to value. """pass

   def get(self, k, d=None): # real signature unknown; restored from __doc__#当key不存在时,返回None,若指定值,返回指定值>>> dic = {"k1":"v1","k2":"v2"}>>> dic.get("k3","123")‘123‘""" D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None. """pass

   def items(self): # real signature unknown; restored from __doc__#返回所有键值对""" D.items() -> a set-like object providing a view on D‘s items """pass

   def keys(self): # real signature unknown; restored from __doc__#返回所有键""" D.keys() -> a set-like object providing a view on D‘s keys """pass

   def pop(self, k, d=None): # real signature unknown; restored from __doc__#指定key删除"""
       D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
       If key is not found, d is returned if given, otherwise KeyError is raised"""pass

   def popitem(self): # real signature unknown; restored from __doc__#随机删除一个"""
       D.popitem() -> (k, v), remove and return some (key, value) pair as a
       2-tuple; but raise KeyError if D is empty."""pass

   def setdefault(self, k, d=None): # real signature unknown; restored from __doc__""" D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D """pass

   def update(self, E=None, **F): # known special case of dict.update#更新字典>>> dic = {"k1":"v1","k2":"v2"}>>> dic.update({"k2":123})>>> dic
{‘k2‘: 123, ‘k1‘: ‘v1‘}"""
       D.update([E, ]**F) -> None.  Update D from dict/iterable E and F.
       If E is present and has a .keys() method, then does:  for k in E: D[k] = E[k]
       If E is present and lacks a .keys() method, then does:  for k, v in E: D[k] = v
       In either case, this is followed by: for k in F:  D[k] = F[k]"""pass

   def values(self): # real signature unknown; restored from __doc__#返回所有值""" D.values() -> an object providing a view on D‘s values """pass

   def __contains__(self, *args, **kwargs): # real signature unknown""" True if D has a key k, else False. """pass

   def __delitem__(self, *args, **kwargs): # real signature unknown""" Delete self[key]. """pass

   def __eq__(self, *args, **kwargs): # real signature unknown""" Return self==value. """pass

   def __getattribute__(self, *args, **kwargs): # real signature unknown""" Return getattr(self, name). """pass

   def __getitem__(self, y): # real signature unknown; restored from __doc__""" x.__getitem__(y) <==> x[y] """pass

   def __ge__(self, *args, **kwargs): # real signature unknown""" Return self>=value. """pass

   def __gt__(self, *args, **kwargs): # real signature unknown""" Return self>value. """pass

   def __init__(self, seq=None, **kwargs): # known special case of dict.__init__"""
       dict() -> new empty dictionary
       dict(mapping) -> new dictionary initialized from a mapping object‘s
           (key, value) pairs
       dict(iterable) -> new dictionary initialized as if via:
           d = {}
           for k, v in iterable:
               d[k] = v
       dict(**kwargs) -> new dictionary initialized with the name=value pairs
           in the keyword argument list.  For example:  dict(one=1, two=2)
       # (copied from class doc)"""pass

   def __iter__(self, *args, **kwargs): # real signature unknown""" Implement iter(self). """pass

   def __len__(self, *args, **kwargs): # real signature unknown""" Return len(self). """pass

   def __le__(self, *args, **kwargs): # real signature unknown""" Return self<=value. """pass

   def __lt__(self, *args, **kwargs): # real signature unknown""" Return self<value. """[email protected] # known case of __new__def __new__(*args, **kwargs): # real signature unknown""" Create and return a new object.  See help(type) for accurate signature. """pass

   def __ne__(self, *args, **kwargs): # real signature unknown""" Return self!=value. """pass

   def __repr__(self, *args, **kwargs): # real signature unknown""" Return repr(self). """pass

   def __setitem__(self, *args, **kwargs): # real signature unknown""" Set self[key] to value. """pass

   def __sizeof__(self): # real signature unknown; restored from __doc__""" D.__sizeof__() -> size of D in memory, in bytes """pass__hash__ = None


以上是关于Python学习第二天的主要内容,如果未能解决你的问题,请参考以下文章

python学习的第二天

2018-10-10学习python第二天

python学习第二天

学习Python第二天

Python学习第二天

python学习第二天