变量

变量作用:保存状态:说白了,程序运行的状态就是状态的变化,变量是用来保存状态的,变量值的不断变化就产生了运行程序的最终输出结果

一:声明变量

 #!/usr/bin/env python
# -*- coding:utf-8 -*-
name='sy'

上述代码声明了一个变量,变量名为: name,变量(name)的值为:"sy"

二:变量的定义规则

  • 变量名只能是 字母、数字或下划线的任意组合
  • 变量名的第一个字符不能是数字(是字母或下划线(_))
  • 大小写敏感
  • 两种风格:conn_obj或ConnObj
  • 不能使用关键字,不能使用内建

以下关键字不能声明为变量名
['and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'not', 'or', 'pass', 'print', 'raise', 'return', 'try', 'while', 'with', 'yield']

三:变量赋值

链式赋值:y=x=z=1

多元赋值:x,y=1,2 x,y=y,x

增量/减量/乘量/除量 赋值:

变量解压赋值:

数据类型

数据类型是在数据结构中的定义是一个值的集合以及定义在这个值集上的一组操作。

一、数据类型分类:

1、数字

int(整型)

python2.*与python3.*关于整型的区别

python2.*
在32位机器上,整数的位数为32位,取值范围为-2**31~2**31-1,即-2147483648~2147483647 在64位系统上,整数的位数为64位,取值范围为-2**63~2**63-1,即-9223372036854775808~9223372036854775807
 class int(object):
"""
int(x=0) -> int or long
int(x, base=10) -> int or long Convert a number or string to an integer, or return 0 if no arguments
are given. If x is floating point, the conversion truncates towards zero.
If x is outside the integer range, the function returns a long instead. If x is not a number or if base is given, then x must be a string or
Unicode object 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)
"""
def bit_length(self):
""" 返回表示该数字的时占用的最少位数 """
"""
int.bit_length() -> int Number of bits necessary to represent self in binary.
>>> bin(37)
'0b100101'
>>> (37).bit_length()
"""
return 0 def conjugate(self, *args, **kwargs): # real signature unknown
""" 返回该复数的共轭复数 """
""" Returns self, the complex conjugate of any int. """
pass def __abs__(self):
""" 返回绝对值 """
""" x.__abs__() <==> abs(x) """
pass def __add__(self, y):
""" x.__add__(y) <==> x+y """
pass def __and__(self, y):
""" x.__and__(y) <==> x&y """
pass def __cmp__(self, y):
""" 比较两个数大小 """
""" x.__cmp__(y) <==> cmp(x,y) """
pass def __coerce__(self, y):
""" 强制生成一个元组 """
""" x.__coerce__(y) <==> coerce(x, y) """
pass def __divmod__(self, y):
""" 相除,得到商和余数组成的元组 """
""" x.__divmod__(y) <==> divmod(x, y) """
pass def __div__(self, y):
""" x.__div__(y) <==> x/y """
pass def __float__(self):
""" 转换为浮点类型 """
""" x.__float__() <==> float(x) """
pass def __floordiv__(self, y):
""" x.__floordiv__(y) <==> x//y """
pass def __format__(self, *args, **kwargs): # real signature unknown
pass def __getattribute__(self, name):
""" x.__getattribute__('name') <==> x.name """
pass def __getnewargs__(self, *args, **kwargs): # real signature unknown
""" 内部调用 __new__方法或创建对象时传入参数使用 """
pass def __hash__(self):
"""如果对象object为哈希表类型,返回对象object的哈希值。哈希值为整数。在字典查找中,哈希值用于快速比较字典的键。两个数值如果相等,则哈希值也相等。"""
""" x.__hash__() <==> hash(x) """
pass def __hex__(self):
""" 返回当前数的 十六进制 表示 """
""" x.__hex__() <==> hex(x) """
pass def __index__(self):
""" 用于切片,数字无意义 """
""" x[y:z] <==> x[y.__index__():z.__index__()] """
pass def __init__(self, x, base=10): # known special case of int.__init__
""" 构造方法,执行 x = 123 或 x = int(10) 时,自动调用,暂时忽略 """
"""
int(x=0) -> int or long
int(x, base=10) -> int or long Convert a number or string to an integer, or return 0 if no arguments
are given. If x is floating point, the conversion truncates towards zero.
If x is outside the integer range, the function returns a long instead. If x is not a number or if base is given, then x must be a string or
Unicode object 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)
# (copied from class doc)
"""
pass def __int__(self):
""" 转换为整数 """
""" x.__int__() <==> int(x) """
pass def __invert__(self):
""" x.__invert__() <==> ~x """
pass def __long__(self):
""" 转换为长整数 """
""" x.__long__() <==> long(x) """
pass def __lshift__(self, y):
""" x.__lshift__(y) <==> x<<y """
pass def __mod__(self, y):
""" x.__mod__(y) <==> x%y """
pass def __mul__(self, y):
""" x.__mul__(y) <==> x*y """
pass def __neg__(self):
""" x.__neg__() <==> -x """
pass @staticmethod # known case of __new__
def __new__(S, *more):
""" T.__new__(S, ...) -> a new object with type S, a subtype of T """
pass def __nonzero__(self):
""" x.__nonzero__() <==> x != 0 """
pass def __oct__(self):
""" 返回改值的 八进制 表示 """
""" x.__oct__() <==> oct(x) """
pass def __or__(self, y):
""" x.__or__(y) <==> x|y """
pass def __pos__(self):
""" x.__pos__() <==> +x """
pass def __pow__(self, y, z=None):
""" 幂,次方 """
""" x.__pow__(y[, z]) <==> pow(x, y[, z]) """
pass def __radd__(self, y):
""" x.__radd__(y) <==> y+x """
pass def __rand__(self, y):
""" x.__rand__(y) <==> y&x """
pass def __rdivmod__(self, y):
""" x.__rdivmod__(y) <==> divmod(y, x) """
pass def __rdiv__(self, y):
""" x.__rdiv__(y) <==> y/x """
pass def __repr__(self):
"""转化为解释器可读取的形式 """
""" x.__repr__() <==> repr(x) """
pass def __str__(self):
"""转换为人阅读的形式,如果没有适于人阅读的解释形式的话,则返回解释器课阅读的形式"""
""" x.__str__() <==> str(x) """
pass def __rfloordiv__(self, y):
""" x.__rfloordiv__(y) <==> y//x """
pass def __rlshift__(self, y):
""" x.__rlshift__(y) <==> y<<x """
pass def __rmod__(self, y):
""" x.__rmod__(y) <==> y%x """
pass def __rmul__(self, y):
""" x.__rmul__(y) <==> y*x """
pass def __ror__(self, y):
""" x.__ror__(y) <==> y|x """
pass def __rpow__(self, x, z=None):
""" y.__rpow__(x[, z]) <==> pow(x, y[, z]) """
pass def __rrshift__(self, y):
""" x.__rrshift__(y) <==> y>>x """
pass def __rshift__(self, y):
""" x.__rshift__(y) <==> x>>y """
pass def __rsub__(self, y):
""" x.__rsub__(y) <==> y-x """
pass def __rtruediv__(self, y):
""" x.__rtruediv__(y) <==> y/x """
pass def __rxor__(self, y):
""" x.__rxor__(y) <==> y^x """
pass def __sub__(self, y):
""" x.__sub__(y) <==> x-y """
pass def __truediv__(self, y):
""" x.__truediv__(y) <==> x/y """
pass def __trunc__(self, *args, **kwargs):
""" 返回数值被截取为整形的值,在整形中无意义 """
pass def __xor__(self, y):
""" x.__xor__(y) <==> x^y """
pass denominator = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
""" 分母 = 1 """
"""the denominator of a rational number in lowest terms""" imag = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
""" 虚数,无意义 """
"""the imaginary part of a complex number""" numerator = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
""" 分子 = 数字大小 """
"""the numerator of a rational number in lowest terms""" real = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
""" 实属,无意义 """
"""the real part of a complex number""" int
python3.*整形长度无限制
 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)
"""
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 0 def conjugate(self, *args, **kwargs): # real signature unknown
""" 返回该复数的共轭复数 """
""" Returns self, the complex conjugate of any int. """
pass @classmethod # known case
def 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.
"""
pass def 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.
"""
pass def __abs__(self, *args, **kwargs): # real signature unknown
""" abs(self) """
pass def __add__(self, *args, **kwargs): # real signature unknown
""" Return self+value. """
pass def __and__(self, *args, **kwargs): # real signature unknown
""" Return self&value. """
pass def __bool__(self, *args, **kwargs): # real signature unknown
""" self != 0 """
pass def __ceil__(self, *args, **kwargs): # real signature unknown
"""
整数返回自己
如果是小数
math.ceil(3.1)返回4
"""
""" Ceiling of an Integral returns itself. """
pass def __divmod__(self, *args, **kwargs): # real signature unknown
""" 相除,得到商和余数组成的元组 """
""" Return divmod(self, value). """
pass def __eq__(self, *args, **kwargs): # real signature unknown
""" Return self==value. """
pass def __float__(self, *args, **kwargs): # real signature unknown
""" float(self) """
pass def __floordiv__(self, *args, **kwargs): # real signature unknown
""" Return self//value. """
pass def __floor__(self, *args, **kwargs): # real signature unknown
""" Flooring an Integral returns itself. """
pass def __format__(self, *args, **kwargs): # real signature unknown
pass def __getattribute__(self, *args, **kwargs): # real signature unknown
""" Return getattr(self, name). """
pass def __getnewargs__(self, *args, **kwargs): # real signature unknown
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 __hash__(self, *args, **kwargs): # real signature unknown
""" Return hash(self). """
pass def __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. """
pass def __init__(self, x, base=10): # known special case of int.__init__
""" 构造方法,执行 x = 123 或 x = int(10) 时,自动调用,暂时忽略 """
"""
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)
# (copied from class doc)
"""
pass def __int__(self, *args, **kwargs): # real signature unknown """ int(self) """
pass def __invert__(self, *args, **kwargs): # real signature unknown
""" ~self """
pass def __le__(self, *args, **kwargs): # real signature unknown
""" Return self<=value. """
pass def __lshift__(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. """
pass def __neg__(self, *args, **kwargs): # real signature unknown
""" -self """
pass @staticmethod # 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 __or__(self, *args, **kwargs): # real signature unknown
""" Return self|value. """
pass def __pos__(self, *args, **kwargs): # real signature unknown
""" +self """
pass def __pow__(self, *args, **kwargs): # real signature unknown
""" Return pow(self, value, mod). """
pass def __radd__(self, *args, **kwargs): # real signature unknown
""" Return value+self. """
pass def __rand__(self, *args, **kwargs): # real signature unknown
""" Return value&self. """
pass def __rdivmod__(self, *args, **kwargs): # real signature unknown
""" Return divmod(value, self). """
pass def __repr__(self, *args, **kwargs): # real signature unknown
""" Return repr(self). """
pass def __rfloordiv__(self, *args, **kwargs): # real signature unknown
""" Return value//self. """
pass def __rlshift__(self, *args, **kwargs): # real signature unknown
""" Return value<<self. """
pass def __rmod__(self, *args, **kwargs): # real signature unknown
""" Return value%self. """
pass def __rmul__(self, *args, **kwargs): # real signature unknown
""" Return value*self. """
pass def __ror__(self, *args, **kwargs): # real signature unknown
""" Return value|self. """
pass def __round__(self, *args, **kwargs): # real signature unknown
"""
Rounding an Integral returns itself.
Rounding with an ndigits argument also returns an integer.
"""
pass def __rpow__(self, *args, **kwargs): # real signature unknown
""" Return pow(value, self, mod). """
pass def __rrshift__(self, *args, **kwargs): # real signature unknown
""" Return value>>self. """
pass def __rshift__(self, *args, **kwargs): # real signature unknown
""" Return self>>value. """
pass def __rsub__(self, *args, **kwargs): # real signature unknown
""" Return value-self. """
pass def __rtruediv__(self, *args, **kwargs): # real signature unknown
""" Return value/self. """
pass def __rxor__(self, *args, **kwargs): # real signature unknown
""" Return value^self. """
pass def __sizeof__(self, *args, **kwargs): # real signature unknown
""" Returns size in memory, in bytes """
pass def __str__(self, *args, **kwargs): # real signature unknown
""" Return str(self). """
pass def __sub__(self, *args, **kwargs): # real signature unknown
""" Return self-value. """
pass def __truediv__(self, *args, **kwargs): # real signature unknown
""" Return self/value. """
pass def __trunc__(self, *args, **kwargs): # real signature unknown
""" Truncating an Integral returns itself. """
pass def __xor__(self, *args, **kwargs): # real signature unknown
""" Return self^value. """
pass denominator = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
"""the denominator of a rational number in lowest terms""" imag = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
"""the imaginary part of a complex number""" numerator = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
"""the numerator of a rational number in lowest terms""" real = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
"""the real part of a complex number""" python3.5

long(长整型)

 python2.*:

跟C语言不同,Python的长整型没有指定位宽,也就是说Python没有限制长整型数值的大小,
但是实际上由于机器内存有限,所以我们使用的长整型数值不可能无限大。
在使用过程中,我们如何区分长整型和整型数值呢?
通常的做法是在数字尾部加上一个大写字母L或小写字母l以表示该整数是长整型的,例如:
a = 9223372036854775808L
注意,自从Python2起,如果发生溢出,Python会自动将整型数据转换为长整型,
所以如今在长整型数据后面不加字母L也不会导致严重后果了。 python3.*
长整型,整型统一归为整型

eg:

  

float(浮点型)

   浮点数也就是小数,之所以称为浮点数,是因为按照科学记数法表示时,一个浮点数的小数点位置是可变的,比如,1.23x109和12.3x108是完全相等的。浮点数可以用数学写法,如1.233.14-9.01,等等。但是对于很大或很小的浮点数,就必须用科学计数法表示,把10用e替代,1.23x109就是1.23e9,或者12.3e8,0.000012可以写成1.2e-5,等等。

    整数和浮点数在计算机内部存储的方式是不同的,整数运算永远是精确的,而浮点数运算则可能会有四舍五入的误差

2、布尔值

  真(True)或假(False)
  0和空,None都是False,其他的全部为True

3:浮点数

浮点数也就是小数,之所以称为浮点数,是因为按照科学记数法表示时,一个浮点数的小数点位置是可变的,比如,1.23x109和12.3x108是完全相等的。浮点数可以用数学写法,如1.233.14-9.01,等等。但是对于很大或很小的浮点数,就必须用科学计数法表示,把10用e替代,1.23x109就是1.23e9,或者12.3e8,0.000012可以写成1.2e-5,等等。

整数和浮点数在计算机内部存储的方式是不同的,整数运算永远是精确的,而浮点数运算则可能会有四舍五入的误差

4:复数

复数由实数部分和虚数部分组成,一般形式为x+yj,其中的x是复数的实数部分,y是复数的虚数部分,这里的x和y都是实数。(虚数部分的字母j大小写都可以)

 >>> 1.3 + 2.5j == 1.3 + 2.5J
True

5:与数字有关的内置函数

二:字符串

定义:

它是一个有序的字符的集合,用于存储和表示基本的文本信息,‘’或“”或‘’‘ ’‘’中间包含的内容称之为字符串

特性:

只能存放一个值

不可变

按照从左到右的顺序定义字符集合,下标从0开始顺序访问,有序

1:字符串创建

a='hello word'

注:单引号和双引号没有任何区别

2:字符串的常用方法

 name="yyp"
print(name.capitalize())#首字母变成大写
print(name.center(30)) # 居中
print(name.center(30,'*'))#居中加填充 msg='hello world'
print(msg.count('l'))#统计出现l在msg中出现的次数
print(msg.count('l',0,3))#统计l在msg中0到3之间l出现的次数
print(msg.count('l',-1))#统计l在msg中最后一个字符中出现l的次数
print(msg.endswith('s'))#判断msg是不是以s结尾,不是则为False,是为True
print(msg.startswith('h'))#判断msg是不是以h开头,不是则为False,是为True
print(msg.find('l'))#统计l出现的位置,如果不存在,则返回-1,存在返回位置,存在多个,只返回第一个出现的位置
print(msg.find('l',3,9))#统计l在msg的3到9之间,l出现的位置
print(msg.index('e'))#index与find本质区别是:index已经知道msg中存在e,然后进行查找,如果不存在会报错。
print(msg.isdigit())#判断字符串中是否包含数字,包含数字为False,不包含为True msg='hello world'#多用于字符串拼接
msg_new='*'.join(msg)
print(msg_new) msg='root:x:0:0:root:/bin/bash'
print(msg.split(':')) #split分割
print(msg.split(':',maxsplit=1))#以:为分割符,最大分割一次 msg_list=msg.split(':')
print(':'.join(msg_list))#按照:拼接字符串 msg='helLo world'
print(msg.upper())#小写转化为大写
print(msg.swapcase())#大小写转换 msg='*****yyp*****'
print(msg.strip('*'))#去掉首尾的指定字符
print(msg.lstrip('*'))#去除左边指定字符
print(msg.rstrip('*'))#去除右边指定字符 print(msg.replace('z','y')) #替换字符,不指定个数全部替换,指定几个就替换几个
print(msg.replace('y','p',1))

3:字符串不常用的方法

 #不常用的方法
msg='hello world'
print(msg.isalpha())#msg是纯字母返回True,不是则返回False
print(msg.isidentifier())#msg是内置标识符,返回True,否则返回False
print(msg.isspace())#msg是空格,返回True,反之,返回False
print(msg.istitle())#msg是标题,也就是首字母大写,返回True
print(msg.ljust(10))#10个字符左对齐
print(msg.ljust(10,'*'))#10个字符左对齐,10个字符*填充
print(msg.rjust(10))#10个字符右对齐
print(msg.rjust(10,'*'))#10个字符右对齐,10个字符*填充
print(msg.zfill(20))#总长度20个,不足则在右边添加0 message='''aaa
bbb
ccc
ddd
'''
print(message.splitlines()) #按照行数切分

4:字符串工厂函数

 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__
"""
原来字符居中,不够用空格补全
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__
"""
从一个范围内的统计某str出现次数
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 0 def encode(self, encoding='utf-8', errors='strict'): # real signature unknown; restored from __doc__
"""
encode(encoding='utf-8',errors='strict')
以encoding指定编码格式编码,如果出错默认报一个ValueError,除非errors指定的是
ignore或replace 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__
"""
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__
"""
将字符串中包含的\t转换成tabsize个空格
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__
"""
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 0 def format(self, *args, **kwargs): # known special case of str.format
"""
格式化输出
三种形式:
形式一.
>>> print('{0}{1}{0}'.format('a','b'))
aba 形式二:(必须一一对应)
>>> print('{}{}{}'.format('a','b'))
Traceback (most recent call last):
File "<input>", line 1, in <module>
IndexError: tuple index out of range
>>> print('{}{}'.format('a','b'))
ab 形式三:
>>> print('{name} {age}'.format(age=12,name='lhf'))
lhf 12 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__
"""
与format区别
'{name}'.format(**dict(name='alex'))
'{name}'.format_map(dict(name='alex')) 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 0 def isalnum(self): # real signature unknown; restored from __doc__
"""
至少一个字符,且都是字母或数字才返回True 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__
"""
至少一个字符,且都是字母才返回True
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__
"""
字符串为关键字返回True 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__
"""
至少一个字符,且都是小写字母才返回True
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__
"""
至少一个字符,且都是空格才返回True
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__
"""
>>> a='Hello'
>>> a.istitle()
True
>>> a='HellP'
>>> a.istitle()
False 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__
"""
#对序列进行操作(分别使用' '与':'作为分隔符)
>>> seq1 = ['hello','good','boy','doiido']
>>> print ' '.join(seq1)
hello good boy doiido
>>> print ':'.join(seq1)
hello:good:boy:doiido #对字符串进行操作 >>> seq2 = "hello good boy doiido"
>>> print ':'.join(seq2)
h:e:l:l:o: :g:o:o:d: :b:o:y: :d:o:i:i:d:o #对元组进行操作 >>> seq3 = ('hello','good','boy','doiido')
>>> print ':'.join(seq3)
hello:good:boy:doiido #对字典进行操作 >>> seq4 = {'hello':1,'good':2,'boy':3,'doiido':4}
>>> print ':'.join(seq4)
boy:good:doiido:hello #合并目录 >>> import os
>>> os.path.join('/hello/','good/boy/','doiido')
'/hello/good/boy/doiido' 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__
"""
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__
"""
以sep为分割,将S分成head,sep,tail三部分 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__
"""
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__
"""
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 0 def 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 0 def 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__
"""
以sep为分割,将S切分成列表,与partition的区别在于切分结果不包含sep,
如果一个字符串中包含多个sep那么maxsplit为最多切分成几部分
>>> a='a,b c\nd\te'
>>> a.split()
['a,b', 'c', 'd', 'e']
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__
"""
Python splitlines() 按照行('\r', '\r\n', \n')分隔,
返回一个包含各行作为元素的列表,如果参数 keepends 为 False,不包含换行符,如 果为 True,则保留换行符。
>>> x
'adsfasdf\nsadf\nasdf\nadf'
>>> x.splitlines()
['adsfasdf', 'sadf', 'asdf', 'adf']
>>> x.splitlines(True)
['adsfasdf\n', 'sadf\n', 'asdf\n', 'adf'] 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__
"""
table=str.maketrans('alex','big SB') a='hello abc'
print(a.translate(table)) 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__
"""
原来字符右对齐,不够用0补齐 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 unknown
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 __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 """
pass @staticmethod # 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

字符串索引,再看解压:

 msg='hello'
#字符串索引操作
print(msg[4])
print(msg[-2])
#字符串的切分操作
print(msg[0:3]) #切分原则:顾头不顾尾
print(msg[0:])
print(msg[:3])
print(msg[0:2000:2])#按两个字符切分
print(msg[::-1])#hello倒过来 #再看变量解压操作
msg='hello'
x,y,z,*_=msg
print(x)
print(y)
print(z)
x,y,z='abc','aaa','xxx'
print(x)
print(y)
print(z)

三:列表

定义:

内以逗号分隔,按照索引,存放各种数据类型,每个位置代表一个元素

特性:

1.可存放多个值
2.可修改指定索引位置对应的值,可变
3.按照从左到右的顺序定义列表元素,下标从0开始顺序访问,有序

1:列表的创建

 name_list=['yyp','sy','lxh','zmh']或name_list=list('yyp')或name=list([’yyp','sy'])

列表常用方法

 name_list=['yyp','sy','lxh','zmh']
#列表的索引操作
print(name_list[-1])
print(name_list[0:2])
print(name_list[::-1])
#列表的内置方法
#append增加到末尾
name_list=['yyp','sy','lxh','zmh']
name_list.append('yy')
print(name_list)
#insert插入到指定位置
name_list=['yyp','sy','lxh','zmh']
name_list.insert(0,'ylqh')
print(name_list)
#pop删除<br>name_list.pop()#默认从右边删除
name_list.pop(2)#指定删除第二个
print(name_list)<br>
#清空列表
name_list=['yyp','sy','lxh','zmh']
name_list.clear()
print(name_list) #复制一份copy
name_list=['yyp','sy','lxh','zmh']
i=name_list.copy()
print(i) #计数
name_list=['yyp','yy','sy','lxh','zmh','yy','zzl']
print(name_list.count('yy'))#yy出现了几次 #两个列表合并
name_list=['yyp','sy','lxh','zmh']
nlist=['ylqi','lift']
name_list.extend(nlist)
print(name_list)
#单独加入列表
every_lis='xxx'
name_list.extend(every_lis)
print(name_list)
<br>#remove移除
name_list=['yyp','sy','lxh','zmh']
name_list.remove(lxhl')#按照元素名移除,有多个重复的元素值时,移除第一个
print(name_list) #reverse反序排列<br>name_list=['yyp','sy','lxh','zmh']
name_list.reverse()#反序
print(name_list)
#sort排列
name_list=['d','c','A','','@','*']
name_list.sort()#按照字符编码表排列
print(name_list)
#统计列表有几个元素或说成列表的长度
name_list=['yyp','sy','lxh','zmh']
print(len(name_list))#统计长度 #判断是否在列表里面
# name_list=['yyp','sy','lxh','zmh']
print ('sy' in name_list)
print ('l' in name_list)

3:列表工厂函数

 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 0 def 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 0 def 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 """
pass @staticmethod # 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

四:元组

定义:

与列表差不多,只不过[]改成(),同时也叫作只读列表

特性:

1.可以存多个值
2.不可变
3.按照从左到右的顺序定义元组元素,下标从0开始顺序访问,有序

1:元组的创建

 msg = (1,2,3,4,5)
##或者
msg = tuple((1,2,3,4,5,6))

2:元组的常用方法

 t=('yyp','sy',123)
print(t.count('sy'))#统计sy的次数
print(t.index('sy'))#统计sy的索引,没有则报错
print(len(t))#统计元组的长度
print('sy' in t) #包含,t是否包含sy

3:元组的工厂函数

 lass tuple(object):
"""
tuple() -> empty tuple
tuple(iterable) -> tuple initialized from iterable's items If the argument is a tuple, the return value is the same object.
"""
def count(self, value): # real signature unknown; restored from __doc__
""" T.count(value) -> integer -- return number of occurrences of value """
return 0 def 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 def __add__(self, y): # real signature unknown; restored from __doc__
""" x.__add__(y) <==> x+y """
pass def __contains__(self, y): # real signature unknown; restored from __doc__
""" x.__contains__(y) <==> y in x """
pass def __eq__(self, y): # real signature unknown; restored from __doc__
""" x.__eq__(y) <==> x==y """
pass def __getattribute__(self, name): # real signature unknown; restored from __doc__
""" x.__getattribute__('name') <==> x.name """
pass def __getitem__(self, y): # real signature unknown; restored from __doc__
""" x.__getitem__(y) <==> x[y] """
pass def __getnewargs__(self, *args, **kwargs): # real signature unknown
pass def __getslice__(self, i, j): # real signature unknown; restored from __doc__
"""
x.__getslice__(i, j) <==> x[i:j] Use of negative indices is not supported.
"""
pass def __ge__(self, y): # real signature unknown; restored from __doc__
""" x.__ge__(y) <==> x>=y """
pass def __gt__(self, y): # real signature unknown; restored from __doc__
""" x.__gt__(y) <==> x>y """
pass def __hash__(self): # real signature unknown; restored from __doc__
""" x.__hash__() <==> hash(x) """
pass def __init__(self, seq=()): # known special case of tuple.__init__
"""
tuple() -> empty tuple
tuple(iterable) -> tuple initialized from iterable's items If the argument is a tuple, the return value is the same object.
# (copied from class doc)
"""
pass def __iter__(self): # real signature unknown; restored from __doc__
""" x.__iter__() <==> iter(x) """
pass def __len__(self): # real signature unknown; restored from __doc__
""" x.__len__() <==> len(x) """
pass def __le__(self, y): # real signature unknown; restored from __doc__
""" x.__le__(y) <==> x<=y """
pass def __lt__(self, y): # real signature unknown; restored from __doc__
""" x.__lt__(y) <==> x<y """
pass def __mul__(self, n): # real signature unknown; restored from __doc__
""" x.__mul__(n) <==> x*n """
pass @staticmethod # known case of __new__
def __new__(S, *more): # real signature unknown; restored from __doc__
""" T.__new__(S, ...) -> a new object with type S, a subtype of T """
pass def __ne__(self, y): # real signature unknown; restored from __doc__
""" x.__ne__(y) <==> x!=y """
pass def __repr__(self): # real signature unknown; restored from __doc__
""" x.__repr__() <==> repr(x) """
pass def __rmul__(self, n): # real signature unknown; restored from __doc__
""" x.__rmul__(n) <==> n*x """
pass def __sizeof__(self): # real signature unknown; restored from __doc__
""" T.__sizeof__() -- size of T in memory, in bytes """
pass

4:元组的不可变行eg

 t = ('yyp', 'sy', ['YYP', 'SY'])
print(t)
t[2][0] = 'Y'
t[2][1] = 'S'
print(t) 输出信息:
('yyp', 'sy', ['YYP', 'SY'])
('yyp', 'sy', ['Y', 'S'])

五:字典

定义:

{key:value},key-value 形式,key必须可hash

特性:

1.可存放多个值

2.可修改指定key对应的值,可变

3.无序

4.可变类型不能当做字典的key,value可以是任何数据类型

5.key不能重复

1:字典的创建

 dic={'name1':'yyp','name2':'sy'}
或者
dic1={(1,2,3):'aa'} #元组可以当做key
或者
dic2 = dict(name='yyp', age=16)
或者
dic3 = dict({"name": "yyp", 'age': 28})
或者
dic4 = dict((['name','yyp'],['age',120])) 输出结果:
{'name1': 'yyp', 'name2': 'sy'}
{(1, 2, 3): 'aa'}
{'name': 'yyp', 'age': 16}
{'name': 'yyp', 'age': 28}
{'name': 'yyp', 'age': 20}

2:字典的常用方法

 取值:
info={'msg1':'yyp','msg2':'sy','msg3':'yp','msg4':'yy'}
print('msg1' in info) #标准用法,存在返回True,不存在返回False
print(info.get('msg2')) #获取
print(info['msg2']) #获取的到的时候,取值 print(info['msg8'])#一旦获取不到,则报错 输出结果:
True
sy
sy Traceback (most recent call last):
File "D:/my/python script/untitled/dict.py", line 21, in <module>
print(info['msg8'])#一旦获取不到,则报错
KeyError: 'msg8' #增加
info={'msg1':'yyp','msg2':'sy'}
print(info)
info['msg3'] = 'yp'#增加
print(info) 结果:
{'msg1': 'yyp', 'msg2': 'sy'}
{'msg1': 'yyp', 'msg2': 'sy', 'msg3': 'yp'} #修改:
info={'msg1':'yyp','msg2':'sy'}
print(info)
info['msg2'] = 'yy' #修改
print(info) 结果:
{'msg1': 'yyp', 'msg2': 'sy'}
{'msg1': 'yyp', 'msg2': 'yy'} 一下五个都为删除用法:
info={'msg1':'yyp','msg2':'sy','msg3':'yp','msg4':'yy'}
print(info)
info.pop('msg3')
print(info)
del info['msg2']
print(info)
info.popitem()# 随机删除一个
print(info) info.clear() #整个列表清空
print(info) 结果:
{'msg1': 'yyp', 'msg2': 'sy', 'msg3': 'yp', 'msg4': 'yy'}
{'msg1': 'yyp', 'msg2': 'sy', 'msg4': 'yy'}
{'msg1': 'yyp', 'msg4': 'yy'}
{'msg1': 'yyp'}
{}

3.字典的其他操作:

多级字典嵌套:

 dict_name = {
"msg1":{
"name1": ["于","one"],
"name2": ["孙","two"],
},
"msg2":{
"name3":["li","whree"]
},
"msg3":{
"name4":["张","four"]
}
} dict_name["msg2"]["name3"][1] += ",你好"
print(dict_name["msg2"]["name3"]) 输出结果:
['li', 'whree,你好']

4:字典的工厂函数

 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 """
pass @staticmethod # known case
def fromkeys(S, v=None): # real signature unknown; restored from __doc__
"""
dict.fromkeys(S[,v]) -> New dict with keys from S and values equal to v.
v defaults to None.
"""
pass def get(self, k, d=None): # real signature unknown; restored from __doc__
""" 根据key获取值,d是默认值 """
""" D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None. """
pass def has_key(self, k): # real signature unknown; restored from __doc__
""" 是否有key """
""" D.has_key(k) -> True if D has a key k, else False """
return False def items(self): # real signature unknown; restored from __doc__
""" 所有项的列表形式 """
""" D.items() -> list of D's (key, value) pairs, as 2-tuples """
return [] def iteritems(self): # real signature unknown; restored from __doc__
""" 项可迭代 """
""" D.iteritems() -> an iterator over the (key, value) items of D """
pass def iterkeys(self): # real signature unknown; restored from __doc__
""" key可迭代 """
""" D.iterkeys() -> an iterator over the keys of D """
pass def itervalues(self): # real signature unknown; restored from __doc__
""" value可迭代 """
""" D.itervalues() -> an iterator over the values of D """
pass def keys(self): # real signature unknown; restored from __doc__
""" 所有的key列表 """
""" D.keys() -> list of D's keys """
return [] def pop(self, k, d=None): # real signature unknown; restored from __doc__
""" 获取并在字典中移除 """
"""
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__
""" 如果key不存在,则创建,如果存在,则返回已存在的值且不修改 """
""" 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
""" 更新
{'name':'alex', 'age': 18000}
[('name','sbsbsb'),]
"""
"""
D.update([E, ]**F) -> None. Update D from dict/iterable E and F.
If E present and has a .keys() method, does: for k in E: D[k] = E[k]
If E present and lacks .keys() method, 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() -> list of D's values """
return [] def viewitems(self): # real signature unknown; restored from __doc__
""" 所有项,只是将内容保存至view对象中 """
""" D.viewitems() -> a set-like object providing a view on D's items """
pass def viewkeys(self): # real signature unknown; restored from __doc__
""" D.viewkeys() -> a set-like object providing a view on D's keys """
pass def viewvalues(self): # real signature unknown; restored from __doc__
""" D.viewvalues() -> an object providing a view on D's values """
pass def __cmp__(self, y): # real signature unknown; restored from __doc__
""" x.__cmp__(y) <==> cmp(x,y) """
pass def __contains__(self, k): # real signature unknown; restored from __doc__
""" D.__contains__(k) -> True if D has a key k, else False """
return False def __delitem__(self, y): # real signature unknown; restored from __doc__
""" x.__delitem__(y) <==> del x[y] """
pass def __eq__(self, y): # real signature unknown; restored from __doc__
""" x.__eq__(y) <==> x==y """
pass def __getattribute__(self, name): # real signature unknown; restored from __doc__
""" x.__getattribute__('name') <==> x.name """
pass def __getitem__(self, y): # real signature unknown; restored from __doc__
""" x.__getitem__(y) <==> x[y] """
pass def __ge__(self, y): # real signature unknown; restored from __doc__
""" x.__ge__(y) <==> x>=y """
pass def __gt__(self, y): # real signature unknown; restored from __doc__
""" x.__gt__(y) <==> x>y """
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): # real signature unknown; restored from __doc__
""" x.__iter__() <==> iter(x) """
pass def __len__(self): # real signature unknown; restored from __doc__
""" x.__len__() <==> len(x) """
pass def __le__(self, y): # real signature unknown; restored from __doc__
""" x.__le__(y) <==> x<=y """
pass def __lt__(self, y): # real signature unknown; restored from __doc__
""" x.__lt__(y) <==> x<y """
pass @staticmethod # known case of __new__
def __new__(S, *more): # real signature unknown; restored from __doc__
""" T.__new__(S, ...) -> a new object with type S, a subtype of T """
pass def __ne__(self, y): # real signature unknown; restored from __doc__
""" x.__ne__(y) <==> x!=y """
pass def __repr__(self): # real signature unknown; restored from __doc__
""" x.__repr__() <==> repr(x) """
pass def __setitem__(self, i, y): # real signature unknown; restored from __doc__
""" x.__setitem__(i, y) <==> x[i]=y """
pass def __sizeof__(self): # real signature unknown; restored from __doc__
""" D.__sizeof__() -> size of D in memory, in bytes """
pass __hash__ = None

六、集合

1:集合的创建

 msg = set([1,2,3])#创建一个数值的集合
print(msg)
或者
msg = set("hello")#创建一个唯一字符的集合
print(msg) 输出结果:
{1, 2, 3}
{'h', 'e', 'o', 'l'}

2:集合的常用操作

 msg = set([1, 1, 2, 2, 3, 3])#重复的元素自动过滤掉
print(msg) 结果:
{1, 2, 3} msg.add(8) #可以添加元素到set中,可以重复添加,但是没有任何效果哦
print(msg) 结果:
{8, 1, 2, 3} msg.remove(1)#删除set中的元素
print(msg) 结果:
{8, 2, 3} msg.update([5,8,6])#在set中添加多项
print(msg) 结果:
{2, 3, 5, 6, 8} print(len(msg))#set的长度
结果:
5

set关系运算

 msg1 = set([2, 3, 5, 6, 8])
msg2 = set([1,3,5])
print(1 in msg1) #测试1是否是msg1的成员,是则返回True,否则返回False 输出结果:
False print(1 not in msg1) #测试1是否不是msg1的成员,是则返回False,不是返回True 输出结果:
True #测试是否msg2中的每一个元素都在msg1中
print(msg2.issubset(msg1))
print(msg2 <= msg1) 输出结果:
False
False #测试msg1中的每个元素都在msg2中
print(msg2.issuperset(msg1))
print(msg2 >= msg1) 输出结果:
False
False #返回一个新的set包含msg1和msg2的每一个元素
print(msg2.union(msg1))
print(msg2 | msg1) 输出结果:
{1, 2, 3, 5, 6, 8}
{1, 2, 3, 5, 6, 8} #返回一个新的set包含msg1与msg2的公共元素
print(msg2.intersection(msg1))
print(msg1 & msg2) 输出结果:
{3, 5}
{3, 5} #返回一个新的set包含msg2中有但是msg1中没有的元素
print(msg2.difference(msg1))
print(msg2 - msg1) 输出结果:
{1}
{1} #返回一个新的set包含msg2和msg1中不重复的元素
print(msg2.symmetric_difference(msg1))
print(msg2 ^ msg1) 输出结果:
{1, 2, 6, 8}
{1, 2, 6, 8} #返回set “msg1”的一个浅的复制
print(msg1.copy()) 输出结果:
{8, 2, 3, 5, 6}

set做交集、并集等操作

msg1 = set([1,3,5])
msg2 = set([1,2,3]) print(msg1 & msg2) #msg1与msg2的交集
print(msg1| msg2 ) #msg1与msg2的并集
print(msg1 - msg2) #求差集(元素在msg1中,但不在msg2中)
print(msg1 ^ msg2) #对称差集(元素在msg1或msg2中,但不会同时出现在二者中) 输出结果: {1, 3}
{1, 2, 3, 5}
{5}
{2, 5}

3:集合工厂

 class set(object):
"""
set() -> new empty set object
set(iterable) -> new set object Build an unordered collection of unique elements.
"""
def add(self, *args, **kwargs): # real signature unknown
"""
Add an element to a set. This has no effect if the element is already present.
"""
pass def clear(self, *args, **kwargs): # real signature unknown
""" Remove all elements from this set. """
pass def copy(self, *args, **kwargs): # real signature unknown
""" Return a shallow copy of a set. """
pass def difference(self, *args, **kwargs): # real signature unknown
"""
相当于s1-s2 Return the difference of two or more sets as a new set. (i.e. all elements that are in this set but not the others.)
"""
pass def difference_update(self, *args, **kwargs): # real signature unknown
""" Remove all elements of another set from this set. """
pass def discard(self, *args, **kwargs): # real signature unknown
"""
与remove功能相同,删除元素不存在时不会抛出异常 Remove an element from a set if it is a member. If the element is not a member, do nothing.
"""
pass def intersection(self, *args, **kwargs): # real signature unknown
"""
相当于s1&s2 Return the intersection of two sets as a new set. (i.e. all elements that are in both sets.)
"""
pass def intersection_update(self, *args, **kwargs): # real signature unknown
""" Update a set with the intersection of itself and another. """
pass def isdisjoint(self, *args, **kwargs): # real signature unknown
""" Return True if two sets have a null intersection. """
pass def issubset(self, *args, **kwargs): # real signature unknown
"""
相当于s1<=s2 Report whether another set contains this set. """
pass def issuperset(self, *args, **kwargs): # real signature unknown
"""
相当于s1>=s2 Report whether this set contains another set. """
pass def pop(self, *args, **kwargs): # real signature unknown
"""
Remove and return an arbitrary set element.
Raises KeyError if the set is empty.
"""
pass def remove(self, *args, **kwargs): # real signature unknown
"""
Remove an element from a set; it must be a member. If the element is not a member, raise a KeyError.
"""
pass def symmetric_difference(self, *args, **kwargs): # real signature unknown
"""
相当于s1^s2 Return the symmetric difference of two sets as a new set. (i.e. all elements that are in exactly one of the sets.)
"""
pass def symmetric_difference_update(self, *args, **kwargs): # real signature unknown
""" Update a set with the symmetric difference of itself and another. """
pass def union(self, *args, **kwargs): # real signature unknown
"""
相当于s1|s2 Return the union of sets as a new set. (i.e. all elements that are in either set.)
"""
pass def update(self, *args, **kwargs): # real signature unknown
""" Update a set with the union of itself and others. """
pass def __and__(self, *args, **kwargs): # real signature unknown
""" Return self&value. """
pass def __contains__(self, y): # real signature unknown; restored from __doc__
""" x.__contains__(y) <==> y in x. """
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 __ge__(self, *args, **kwargs): # real signature unknown
""" Return self>=value. """
pass def __gt__(self, *args, **kwargs): # real signature unknown
""" Return self>value. """
pass def __iand__(self, *args, **kwargs): # real signature unknown
""" Return self&=value. """
pass def __init__(self, seq=()): # known special case of set.__init__
"""
set() -> new empty set object
set(iterable) -> new set object Build an unordered collection of unique elements.
# (copied from class doc)
"""
pass def __ior__(self, *args, **kwargs): # real signature unknown
""" Return self|=value. """
pass def __isub__(self, *args, **kwargs): # real signature unknown
""" Return self-=value. """
pass def __iter__(self, *args, **kwargs): # real signature unknown
""" Implement iter(self). """
pass def __ixor__(self, *args, **kwargs): # real signature unknown
""" Return self^=value. """
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 @staticmethod # 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 __or__(self, *args, **kwargs): # real signature unknown
""" Return self|value. """
pass def __rand__(self, *args, **kwargs): # real signature unknown
""" Return value&self. """
pass def __reduce__(self, *args, **kwargs): # real signature unknown
""" Return state information for pickling. """
pass def __repr__(self, *args, **kwargs): # real signature unknown
""" Return repr(self). """
pass def __ror__(self, *args, **kwargs): # real signature unknown
""" Return value|self. """
pass def __rsub__(self, *args, **kwargs): # real signature unknown
""" Return value-self. """
pass def __rxor__(self, *args, **kwargs): # real signature unknown
""" Return value^self. """
pass def __sizeof__(self): # real signature unknown; restored from __doc__
""" S.__sizeof__() -> size of S in memory, in bytes """
pass def __sub__(self, *args, **kwargs): # real signature unknown
""" Return self-value. """
pass def __xor__(self, *args, **kwargs): # real signature unknown
""" Return self^value. """
pass __hash__ = None

循环区别:

字符串循环:

 #字符串循环:
方法1:
msg='love'
for i in msg:
print(i) 结果:
l
o
v
e 方法2:
for i in enumerate(msg):
print(i) 结果:
(0, 'l')
(1, 'o')
(2, 'v')
(3, 'e') 方法3:倒叙循环
for i in msg[::-1]:
print(i)

列表循环:

 lis=['yyp','sy','yy']
for i in lis:
print(i) for i in enumerate(lis):
print(i) 结果:
yyp
sy
yy
(0, 'yyp')
(1, 'sy')
(2, 'yy')

元组循环:

 tup=('x','y','z')
for i in tup:
print(i) for i in enumerate(tup):
print(i) 结果:
x
y
z
(0, 'x')
(1, 'y')
(2, 'z')

字典循环:

 #字典循环
info={'msg1':'yyp','msg2':'sy','msg3':'zl','msg4':'yy'}
#方法1
for key in info:
print(key,info[key]) 结果
msg1 yyp
msg2 sy
msg3 zl
msg4 yy #方法2
for k,v in info.items(): #会先把dict转成list,数据大时最好不要用
print(k,v) 结果:
msg1 yyp
msg2 sy
msg3 zl
msg4 yy info={'name1':'yyp','name2':'sy','name3':'yy'}
方法3:
info={'name1':'yyp','name2':'sy','name3':'yy'}
for i in enumerate(info):
print(i) 结果:
(0, 'name1')
(1, 'name2')
(2, 'name3') 方法4:
for i in info.keys():
print(i,info[i]) 结果:
name1 yyp
name2 sy
name3 yy 方法5:
for v in info.values():
print(v) 结果:
yyp
sy
yy

列表转为其他类型:

列表不可以转为字典

 nums=[1,3,5,7,8,0]

 #列表转为字符串:
print(str(nums),type(str(nums))) 结果:
[1, 3, 5, 7, 8, 0] <class 'str'> #列表转为元组:
print(tuple(nums),type(tuple(nums)))
结果:
(1, 3, 5, 7, 8, 0) <class 'tuple'>

元组转为其他类型:

元组不可以转为字典

 tup=(1, 2, 3, 4, 5)

 #元组转为字符串
print(tup.__str__(),type(tup.__str__())) 结果:
(1, 2, 3, 4, 5) <class 'str'> #元组转为列表
print(list(tup),type(list(tup))) 结果:
[1, 2, 3, 4, 5] <class 'list'>

字典转为其他类型:

 dic = {'name': 'Zara', 'age': 7, 'class': 'First'}

 #字典转为字符串
print(str(dic),type(str(dic))) 结果:
{'age': 7, 'name': 'Zara', 'class': 'First'} <class 'str'> #字典可以转为元组
print(tuple(dic),type(tuple(dic)))
#字典可以转为元组
print(tuple(dic.values()),type(tuple(dic.values()))) 结果:
('age', 'name', 'class') <class 'tuple'>
(7, 'Zara', 'First') <class 'tuple'> #字典转为列表
print(list(dic),type(list(dic)))
#字典转为列表
print(list(dic.values()),type(list(dic.values()))) 结果:
['age', 'name', 'class'] <class 'list'>
[7, 'Zara', 'First'] <class 'list'>
分类: python

总结

1.按存值个数区分

标量/原子类型 数字,字符串
容器类型 列表,元组,字典

2.按可变不可变区分

可变 列表,字典
不可变 数字,字符串,元组

证明:可变/不可变

更改数据类型其中的元素,如果内存地址发生变化,则为不可变类型,如果内存地址没有发生变化,则为可变类型。

详情参考:http://www.cnblogs.com/ylqh/p/6388330.html 的内存管理

3.按访问顺序区分

直接访问 数字
顺序访问(序列类型) 字符串,列表,元组
key值访问(映射类型) 字典

补充:字典占用的内存空间比列表大,(因为要在内存空间保存一端时间的hash表)但是字典查询速度比列表快,联想到非关系型数据库比关系型数据查询要快应该就会想明白。

Python学习之路2☞数据类型与变量的更多相关文章

  1. python学习之路-基本数据类型1 变量的概念、数字、字符串

    1 什么是数据类型? 每种编程语言都有自己的数据类型,用于标识计算机可以认识的数据,Python中主要的数据类型为字符串,整数,浮点数,列表,元祖,字典,集合七种主要的数据类型,其中以列表,字典为最主 ...

  2. Python 学习随笔 - 1 - 基础数据类型、变量 及 基本运算

    仅有的C语言的基础都是大学时学的: 准备赶潮流,开始学习Python. 随笔记录学习过程中,靠一点点C语言基础难以去理解的地方,以及区别于C语言的地方,做些笔记作为以后参考. Python 解释器直接 ...

  3. python学习之路-day2-pyth基础2

    一.        模块初识 Python的强大之处在于他有非常丰富和强大的标准库和第三方库,第三方库存放位置:site-packages sys模块简介 导入模块 import sys 3 sys模 ...

  4. Python学习之路-Day2-Python基础2

    Python学习之路第二天 学习内容: 1.模块初识 2.pyc是什么 3.python数据类型 4.数据运算 5.bytes/str之别 6.列表 7.元组 8.字典 9.字符串常用操作 1.模块初 ...

  5. Python学习之路【第一篇】-Python简介和基础入门

    1.Python简介 1.1 Python是什么 相信混迹IT界的很多朋友都知道,Python是近年来最火的一个热点,没有之一.从性质上来讲它和我们熟知的C.java.php等没有什么本质的区别,也是 ...

  6. Python学习之路-Day2-Python基础3

    Python学习之路第三天 学习内容: 1.文件操作 2.字符转编码操作 3.函数介绍 4.递归 5.函数式编程 1.文件操作 打印到屏幕 最简单的输出方法是用print语句,你可以给它传递零个或多个 ...

  7. Python学习之路-Day1-Python基础

    学习python的过程: 在茫茫的编程语言中我选择了python,因为感觉python很强大,能用到很多领域.我自己也学过一些编程语言,比如:C,java,php,html,css等.但是我感觉自己都 ...

  8. python学习日记(基础数据类型及其方法01)

    数字 int 主要是用于计算的,常用的方法有一种 #既十进制数值用二进制表示时,最少使用的位数i = 3#3的ASCII为:0000 0011,即两位 s = i.bit_length() print ...

  9. Python学习之路——pycharm的第一个项目

    Python学习之路——pycharm的第一个项目 简介: 上文中已经介绍如何安装Pycharm已经环境变量的配置.现在软件已经安装成功,现在就开始动手做第一个Python项目.第一个“Hello W ...

随机推荐

  1. 爬虫(四)Selenium + Headless Chrome爬取Bing图片搜索结果

    Bing图片搜索结果是动态加载的,如果我们直接用requests去访问页面爬取数据,那我们只能拿到很少的图片.所以我们使用Selenium + Headless Chrome来爬取搜索结果.在开始前, ...

  2. 评价目标检测(object detection)模型的参数:IOU,AP,mAP

    首先我们为什么要使用这些呢? 举个简单的例子,假设我们图像里面只有1个目标,但是定位出来10个框,1个正确的,9个错误的,那么你要按(识别出来的正确的目标/总的正确目标)来算,正确率100%,但是其实 ...

  3. 跟我一起做一个vue的小项目(十)

    接下来我们对城市列表页面进行优化,除了对数据优化,也会进行节流处理 //src\pages\city\components\Alphabet.vue <template> <ul c ...

  4. php 5.4 windows2003 iis 安装 注意

    php5.3 以上 不再支持ISAPI模式 只能用 FastCGI ....

  5. promise的实现方式和运行机制

    promise的规范其实种类很多,我们最常用的是promise/A+ 这篇文章会先将一个类似于promise的构造函数怎么写,网上很多教程并没有实现A+规范,只是看起来像而已 然后我们深入探究如何一步 ...

  6. 读书笔记--Head First JavaScript 目录

    1.交互式网络 2.存储数据 3.探索客户端 4.决策 5.循环 6.函数 7.表单与验证 8.驾驭网页 9.为数据带来生命 10.创建自定义对象 11.除错务尽 12.动态数据

  7. pip在多个python版本中将包安装到制定版本

    $ pip install -t /usr/local/lib/python3./site-package/ beautifulsoup4 利用pip install -t 制定到具体位置

  8. 你应该知道的25个非常有用的CSS技巧

    在我们的前端CSS编码当中,经常要设置特殊的字体效果,边框圆角等等,还要考虑兼容性的问题, CSS网页布局,说难,其实很简单. 说它容易,往往有很多问题困扰着新手,在中介绍了非常多的技巧,这些小技巧与 ...

  9. LINUX下C++编程如何获得某进程的ID

    #include <stdio.h> #include <stdlib.h> #include <unistd.h> using namespace std; pi ...

  10. update批量更新某一列成其它列对应的值【原】

    update批量更新某一列成其它列对应的值 postgresql 标准sql语句 update AA set name = BB.name , AA.sex = BB.sex from BB wher ...