当前位置: 首页 > 编程日记 > 正文

Python学习【第七篇】基本数据类型

基本数据类型

bytes数据类型

Python 3最重要的新特性大概要算是对文本和二进制数据作了更为清晰的区分。文本总是Unicode,由str类型表示,二进制数据则由bytes类型表示。Python 3不会以任意隐式的方式混用str和bytes,正是这使得两者的区分特别清晰。你不能拼接字符串和字节包,也无法在字节包里搜索字符串(反之亦然),也不能将字符串传入参数为字节包的函数(反之亦然)。这是件好事。

不管怎样,字符串和字节包之间的界线是必然的,下面的图解非常重要,务请牢记于心:

字符串可以编码成字节包,而字节包可以解码成字符串。

>>>'€20'.encode('utf-8')
b'\xe2\x82\xac20'
>>> b'\xe2\x82\xac20'.decode('utf-8')
'€20'

数字

2是一个整数的例子。

长整数 不过是大一些的整数。

3.23和52.3E-4是浮点数的例子,E标记表示10的幂。在这里,52.3E-4表示52.3*10-4.

(-5+4j)和(2.3-4.6j)是复数的例子,其中-5,4为实数,j为虚数,数学中表示复数是什么?。

int(整型)

在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 longint(x, base=10) -> int or longConvert a number or string to an integer, or return 0 if no argumentsare 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 orUnicode object representing an integer literal in the given base.  Theliteral 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 tointerpret the base from the string as an integer literal.>>> int('0b100', base=0)"""def bit_length(self): """ 返回表示该数字的时占用的最少位数 """"""int.bit_length() -> intNumber 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 __abs__(self):""" 返回绝对值 """""" x.__abs__() <==> abs(x) """passdef __add__(self, y):""" x.__add__(y) <==> x+y """passdef __and__(self, y):""" x.__and__(y) <==> x&y """passdef __cmp__(self, y): """ 比较两个数大小 """""" x.__cmp__(y) <==> cmp(x,y) """passdef __coerce__(self, y):""" 强制生成一个元组 """ """ x.__coerce__(y) <==> coerce(x, y) """passdef __divmod__(self, y): """ 相除,得到商和余数组成的元组 """ """ x.__divmod__(y) <==> divmod(x, y) """passdef __div__(self, y): """ x.__div__(y) <==> x/y """passdef __float__(self): """ 转换为浮点类型 """ """ x.__float__() <==> float(x) """passdef __floordiv__(self, y): """ x.__floordiv__(y) <==> x//y """passdef __format__(self, *args, **kwargs): # real signature unknownpassdef __getattribute__(self, name): """ x.__getattribute__('name') <==> x.name """passdef __getnewargs__(self, *args, **kwargs): # real signature unknown""" 内部调用 __new__方法或创建对象时传入参数使用 """ passdef __hash__(self): """如果对象object为哈希表类型,返回对象object的哈希值。哈希值为整数。在字典查找中,哈希值用于快速比较字典的键。两个数值如果相等,则哈希值也相等。"""""" x.__hash__() <==> hash(x) """passdef __hex__(self): """ 返回当前数的 十六进制 表示 """ """ x.__hex__() <==> hex(x) """passdef __index__(self): """ 用于切片,数字无意义 """""" x[y:z] <==> x[y.__index__():z.__index__()] """passdef __init__(self, x, base=10): # known special case of int.__init__""" 构造方法,执行 x = 123 或 x = int(10) 时,自动调用,暂时忽略 """ """int(x=0) -> int or longint(x, base=10) -> int or longConvert a number or string to an integer, or return 0 if no argumentsare 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 orUnicode object representing an integer literal in the given base.  Theliteral 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 tointerpret the base from the string as an integer literal.>>> int('0b100', base=0)# (copied from class doc)"""passdef __int__(self): """ 转换为整数 """ """ x.__int__() <==> int(x) """passdef __invert__(self): """ x.__invert__() <==> ~x """passdef __long__(self): """ 转换为长整数 """ """ x.__long__() <==> long(x) """passdef __lshift__(self, y): """ x.__lshift__(y) <==> x<<y """passdef __mod__(self, y): """ x.__mod__(y) <==> x%y """passdef __mul__(self, y): """ x.__mul__(y) <==> x*y """passdef __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 """passdef __nonzero__(self): """ x.__nonzero__() <==> x != 0 """passdef __oct__(self): """ 返回改值的 八进制 表示 """ """ x.__oct__() <==> oct(x) """passdef __or__(self, y): """ x.__or__(y) <==> x|y """passdef __pos__(self): """ x.__pos__() <==> +x """passdef __pow__(self, y, z=None): """ 幂,次方 """ """ x.__pow__(y[, z]) <==> pow(x, y[, z]) """passdef __radd__(self, y): """ x.__radd__(y) <==> y+x """passdef __rand__(self, y): """ x.__rand__(y) <==> y&x """passdef __rdivmod__(self, y): """ x.__rdivmod__(y) <==> divmod(y, x) """passdef __rdiv__(self, y): """ x.__rdiv__(y) <==> y/x """passdef __repr__(self): """转化为解释器可读取的形式 """""" x.__repr__() <==> repr(x) """passdef __str__(self): """转换为人阅读的形式,如果没有适于人阅读的解释形式的话,则返回解释器课阅读的形式"""""" x.__str__() <==> str(x) """passdef __rfloordiv__(self, y): """ x.__rfloordiv__(y) <==> y//x """passdef __rlshift__(self, y): """ x.__rlshift__(y) <==> y<<x """passdef __rmod__(self, y): """ x.__rmod__(y) <==> y%x """passdef __rmul__(self, y): """ x.__rmul__(y) <==> y*x """passdef __ror__(self, y): """ x.__ror__(y) <==> y|x """passdef __rpow__(self, x, z=None): """ y.__rpow__(x[, z]) <==> pow(x, y[, z]) """passdef __rrshift__(self, y): """ x.__rrshift__(y) <==> y>>x """passdef __rshift__(self, y): """ x.__rshift__(y) <==> x>>y """passdef __rsub__(self, y): """ x.__rsub__(y) <==> y-x """passdef __rtruediv__(self, y): """ x.__rtruediv__(y) <==> y/x """passdef __rxor__(self, y): """ x.__rxor__(y) <==> y^x """passdef __sub__(self, y): """ x.__sub__(y) <==> x-y """passdef __truediv__(self, y): """ x.__truediv__(y) <==> x/y """passdef __trunc__(self, *args, **kwargs): """ 返回数值被截取为整形的值,在整形中无意义 """passdef __xor__(self, y): """ x.__xor__(y) <==> x^y """passdenominator = 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
int

long(长整型)

跟C语言不同,Python的长整数没有指定位宽,即:Python没有限制长整数数值的大小,但实际上由于机器内存有限,我们使用的长整数数值不可能无限大。

注意,自从Python2.2起,如果整数发生溢出,Python会自动将整数数据转换为长整数,所以如今在长整数数据后面不加字母L也不会导致严重后果了。

float (浮点型)

浮点数用来处理实数,即带有小数的数字。类似于C语言中的double类型,占8个字节(64位),其中52位表示底,11位表示指数,剩下的一位表示符号。

complex(复数)

复数由实数部分和虚数部分组成,一般形式为x + yj,其中的x是复数的实数部分,y是复数的虚数部分,这里的x和y都是实数。

注:Python中存在小数池-5~257

布尔值

布尔值在Python中如何定义呢?
>>>True
True
>>>False
False#注意!都是大写

真或假

1或0

>>>0 == True
False
>>>0 == False
True#由此可见0代表False,而1代表True

字符串

"Hello world"

万恶的字符串拼接:

python中的字符串在C语言中体现为是一个字符数组,每次创建字符串时候需要在内存中开辟一块连续的空,并且一旦需要修改字符串的话,就需要再次开辟空间,万恶的+号每出现一次就会在内存中重新开辟一块空间像下面这样,所以我们要尽量避免这样的情况发生:

>>>name = 'bourbon'#开辟了3快内存空间,需要去内存里找3次,把数据拼出来
>>>print("my name is " + name + "and you ?") #输出
my name is bourbon and you ?

字符串格式化

>>>name='bourbon'
>>>print "i am %s" %name#输出 
i am bourbon

PS:字符串是%s;整数%d;浮点数%f

 1 name = input("input your name:")
 2 age = int(input("input your age:"))
 3 job = input("input your job:")
 4 
 5 msg = '''
 6 information of user %s:
 7 ----------------------
 8 name:   %s
 9 age :   %d
10 job :   %s
11 --------End-----------
12 ''' % (name,name,age,job )
13 print(msg)
View Code

字符串功能:

· 移除空白

username = input("input your name:")
if username.strip() == "bourbon":print("welcome")#strip() 移除首尾的空白

· 分割

>>>name = "bourbon,jacky,lio"
>>>name2 = name.split(",")
>>>print(name2)
#按照","进行拆分,将字符串拆成一个列表
['bourbon', 'jacky', 'lio']  >>>name = "bourbon,jacky,lio"
>>>name2 = name.split(",")
>>>print("|".join(name2))
#按照"|"将列表里的每一个元素重新合成一个新的字符串
bourbon|jacky|lio

· 长度

· 索引

· 切片

name = "Bourbon Tian"
print(name[2:4])# 输出
ur

name = "sheldon"# 以什么结尾
print(name.endswith("on"))  # 以什么开头
print(name.startswith("on"))  # 全大写
print(name.upper())# 全小写
print(name.lower())  # 输出
True
False
SHELDON
sheldon

>>>name = "bourbon tian"
>>>print(name.center(40,'-'))
--------------bourbon tian--------------

class str(basestring):"""str(object='') -> stringReturn a nice string representation of the object.If the argument is a string, the return value is the same object."""def capitalize(self):  """ 首字母变大写 """"""S.capitalize() -> stringReturn a copy of the string S with only its first charactercapitalized."""return ""def center(self, width, fillchar=None):  """ 内容居中,width:总长度;fillchar:空白处填充内容,默认无 """"""S.center(width[, fillchar]) -> stringReturn S centered in a string of length width. Padding isdone using the specified fill character (default is a space)"""return ""def count(self, sub, start=None, end=None):  """ 子序列个数 """"""S.count(sub[, start[, end]]) -> intReturn the number of non-overlapping occurrences of substring sub instring S[start:end].  Optional arguments start and end are interpretedas in slice notation."""return 0def decode(self, encoding=None, errors=None):  """ 解码 """"""S.decode([encoding[,errors]]) -> objectDecodes S using the codec registered for encoding. encoding defaultsto the default encoding. errors may be given to set a different errorhandling scheme. Default is 'strict' meaning that encoding errors raisea UnicodeDecodeError. Other possible values are 'ignore' and 'replace'as well as any other name registered with codecs.register_error that isable to handle UnicodeDecodeErrors."""return object()def encode(self, encoding=None, errors=None):  """ 编码,针对unicode """"""S.encode([encoding[,errors]]) -> objectEncodes S using the codec registered for encoding. encoding defaultsto the default encoding. errors may be given to set a different errorhandling scheme. Default is 'strict' meaning that encoding errors raisea UnicodeEncodeError. Other possible values are 'ignore', 'replace' and'xmlcharrefreplace' as well as any other name registered withcodecs.register_error that is able to handle UnicodeEncodeErrors."""return object()def endswith(self, suffix, start=None, end=None):  """ 是否以 xxx 结束 """"""S.endswith(suffix[, start[, end]]) -> boolReturn 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 Falsedef expandtabs(self, tabsize=None):  """ 将tab转换成空格,默认一个tab转换成8个空格 """"""S.expandtabs([tabsize]) -> stringReturn 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):  """ 寻找子序列位置,如果没找到,返回 -1 """"""S.find(sub [,start [,end]]) -> intReturn the lowest index in S where substring sub is found,such that sub is contained within S[start:end].  Optionalarguments 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) -> stringReturn a formatted version of S, using substitutions from args and kwargs.The substitutions are identified by braces ('{' and '}')."""passdef index(self, sub, start=None, end=None):  """ 子序列位置,如果没找到,报错 """S.index(sub [,start [,end]]) -> intLike S.find() but raise ValueError when the substring is not found."""return 0def isalnum(self):  """ 是否是字母和数字 """"""S.isalnum() -> boolReturn True if all characters in S are alphanumericand there is at least one character in S, False otherwise."""return Falsedef isalpha(self):  """ 是否是字母 """"""S.isalpha() -> boolReturn True if all characters in S are alphabeticand there is at least one character in S, False otherwise."""return Falsedef isdigit(self):  """ 是否是数字 """"""S.isdigit() -> boolReturn True if all characters in S are digitsand there is at least one character in S, False otherwise."""return Falsedef islower(self):  """ 是否小写 """"""S.islower() -> boolReturn True if all cased characters in S are lowercase and there isat least one cased character in S, False otherwise."""return Falsedef isspace(self):  """S.isspace() -> boolReturn True if all characters in S are whitespaceand there is at least one character in S, False otherwise."""return Falsedef istitle(self):  """S.istitle() -> boolReturn True if S is a titlecased string and there is at least onecharacter in S, i.e. uppercase characters may only follow uncasedcharacters and lowercase characters only cased ones. Return Falseotherwise."""return Falsedef isupper(self):  """S.isupper() -> boolReturn True if all cased characters in S are uppercase and there isat least one cased character in S, False otherwise."""return Falsedef join(self, iterable):  """ 连接 """"""S.join(iterable) -> stringReturn a string which is the concatenation of the strings in theiterable.  The separator between elements is S."""return ""def ljust(self, width, fillchar=None):  """ 内容左对齐,右侧填充 """"""S.ljust(width[, fillchar]) -> stringReturn S left-justified in a string of length width. Padding isdone using the specified fill character (default is a space)."""return ""def lower(self):  """ 变小写 """"""S.lower() -> stringReturn a copy of the string S converted to lowercase."""return ""def lstrip(self, chars=None):  """ 移除左侧空白 """"""S.lstrip([chars]) -> string or unicodeReturn a copy of the string S with leading whitespace removed.If chars is given and not None, remove characters in chars instead.If chars is unicode, S will be converted to unicode before stripping"""return ""def partition(self, sep):  """ 分割,前,中,后三部分 """"""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 notfound, return S and two empty strings."""passdef replace(self, old, new, count=None):  """ 替换 """"""S.replace(old, new[, count]) -> stringReturn a copy of string S with all occurrences of substringold replaced by new.  If the optional argument count isgiven, only the first count occurrences are replaced."""return ""def rfind(self, sub, start=None, end=None):  """S.rfind(sub [,start [,end]]) -> intReturn the highest index in S where substring sub is found,such that sub is contained within S[start:end].  Optionalarguments start and end are interpreted as in slice notation.Return -1 on failure."""return 0def rindex(self, sub, start=None, end=None):  """S.rindex(sub [,start [,end]]) -> intLike S.rfind() but raise ValueError when the substring is not found."""return 0def rjust(self, width, fillchar=None):  """S.rjust(width[, fillchar]) -> stringReturn S right-justified in a string of length width. Padding isdone using the specified fill character (default is a space)"""return ""def rpartition(self, sep):  """S.rpartition(sep) -> (head, sep, tail)Search for the separator sep in S, starting at the end of S, and returnthe part before it, the separator itself, and the part after it.  If theseparator is not found, return two empty strings and S."""passdef rsplit(self, sep=None, maxsplit=None):  """S.rsplit([sep [,maxsplit]]) -> list of stringsReturn a list of the words in the string S, using sep as thedelimiter string, starting at the end of the string and workingto the front.  If maxsplit is given, at most maxsplit splits aredone. If sep is not specified or is None, any whitespace stringis a separator."""return []def rstrip(self, chars=None):  """S.rstrip([chars]) -> string or unicodeReturn a copy of the string S with trailing whitespace removed.If chars is given and not None, remove characters in chars instead.If chars is unicode, S will be converted to unicode before stripping"""return ""def split(self, sep=None, maxsplit=None):  """ 分割, maxsplit最多分割几次 """"""S.split([sep [,maxsplit]]) -> list of stringsReturn a list of the words in the string S, using sep as thedelimiter string.  If maxsplit is given, at most maxsplitsplits are done. If sep is not specified or is None, anywhitespace string is a separator and empty strings are removedfrom the result."""return []def splitlines(self, keepends=False):  """ 根据换行分割 """"""S.splitlines(keepends=False) -> list of stringsReturn a list of the lines in S, breaking at line boundaries.Line breaks are not included in the resulting list unless keependsis given and true."""return []def startswith(self, prefix, start=None, end=None):  """ 是否起始 """"""S.startswith(prefix[, start[, end]]) -> boolReturn 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 Falsedef strip(self, chars=None):  """ 移除两段空白 """"""S.strip([chars]) -> string or unicodeReturn a copy of the string S with leading and trailingwhitespace removed.If chars is given and not None, remove characters in chars instead.If chars is unicode, S will be converted to unicode before stripping"""return ""def swapcase(self):  """ 大写变小写,小写变大写 """"""S.swapcase() -> stringReturn a copy of the string S with uppercase charactersconverted to lowercase and vice versa."""return ""def title(self):  """S.title() -> stringReturn a titlecased version of S, i.e. words start with uppercasecharacters, all remaining cased characters have lowercase."""return ""def translate(self, table, deletechars=None):  """转换,需要先做一个对应表,最后一个表示删除字符集合intab = "aeiou"outtab = "12345"trantab = maketrans(intab, outtab)str = "this is string example....wow!!!"print str.translate(trantab, 'xm')""""""S.translate(table [,deletechars]) -> stringReturn a copy of the string S, where all characters occurringin the optional argument deletechars are removed, and theremaining characters have been mapped through the giventranslation table, which must be a string of length 256 or None.If the table argument is None, no translation is applied andthe operation simply removes the characters in deletechars."""return ""def upper(self):  """S.upper() -> stringReturn a copy of the string S converted to uppercase."""return ""def zfill(self, width):  """方法返回指定长度的字符串,原字符串右对齐,前面填充0。""""""S.zfill(width) -> stringPad a numeric string S with zeros on the left, to fill a fieldof the specified width.  The string S is never truncated."""return ""def _formatter_field_name_split(self, *args, **kwargs): # real signature unknownpassdef _formatter_parser(self, *args, **kwargs): # real signature unknownpassdef __add__(self, y):  """ x.__add__(y) <==> x+y """passdef __contains__(self, y):  """ x.__contains__(y) <==> y in x """passdef __eq__(self, y):  """ x.__eq__(y) <==> x==y """passdef __format__(self, format_spec):  """S.__format__(format_spec) -> stringReturn a formatted version of S as described by format_spec."""return ""def __getattribute__(self, name):  """ x.__getattribute__('name') <==> x.name """passdef __getitem__(self, y):  """ x.__getitem__(y) <==> x[y] """passdef __getnewargs__(self, *args, **kwargs): # real signature unknownpassdef __getslice__(self, i, j):  """x.__getslice__(i, j) <==> x[i:j]Use of negative indices is not supported."""passdef __ge__(self, y):  """ x.__ge__(y) <==> x>=y """passdef __gt__(self, y):  """ x.__gt__(y) <==> x>y """passdef __hash__(self):  """ x.__hash__() <==> hash(x) """passdef __init__(self, string=''): # known special case of str.__init__"""str(object='') -> stringReturn a nice string representation of the object.If the argument is a string, the return value is the same object.# (copied from class doc)"""passdef __len__(self):  """ x.__len__() <==> len(x) """passdef __le__(self, y):  """ x.__le__(y) <==> x<=y """passdef __lt__(self, y):  """ x.__lt__(y) <==> x<y """passdef __mod__(self, y):  """ x.__mod__(y) <==> x%y """passdef __mul__(self, n):  """ x.__mul__(n) <==> x*n """pass@staticmethod # known case of __new__def __new__(S, *more):  """ T.__new__(S, ...) -> a new object with type S, a subtype of T """passdef __ne__(self, y):  """ x.__ne__(y) <==> x!=y """passdef __repr__(self):  """ x.__repr__() <==> repr(x) """passdef __rmod__(self, y):  """ x.__rmod__(y) <==> y%x """passdef __rmul__(self, n):  """ x.__rmul__(n) <==> n*x """passdef __sizeof__(self):  """ S.__sizeof__() -> size of S in memory, in bytes """passdef __str__(self):  """ x.__str__() <==> str(x) """pass
str

列表

创建列表:

>>>age = 9
>>>name = ["jack","jerry","jason",22,age]
>>>print(name)
['jack','jerry','jason',22,9]

列表都是"[]"号开始,通过","隔开,字符串是元素,元素也可以是数字、变量。

基本操作:

· 索引

第一个索引是0,第二个索引是1,以此类推。

>>>name[0]
'jack'
>>>name[1]
'jerry'
>>>name[-1]
9
>>>name[-2]
22

· 切片

>>>name[0:2]
#虎头蛇尾,永远不包含最后一个
['jack','jerry']
>>>name[0:2][0]
'jack'
>>>name[0:2][0][1]
'a'

PS:只能正着取值

· 更改插入追加

#更改
>>>name[1] = "bourbon"
>>>name
['jack','bourbon','jason',22,9]#插入
>>>name.insert(2,'lio')
>>>name
['jack','bourbon','lio','jason',22,9]#追加
>>>name.append("eric")
>>>name
['jack','bourbon','lio','jason',22,9,'eric']

· 删除

>>>name.remove("lio")
>>>name
['jack','bourbon','jason',22,9,'eric']>>>del name[1]
>>>name
['jack','jason',22,9,'eric']#name.pop(“这里输入下标”) ,默认删除最后一个下标。
>>>name.pop()
'eric'
>>>name
['jack','jason',22,9]

· 长度

· 循环

· 包含

扩展表
>>>name = [32,23,21,52,14,546,7,68,76,98,5435,2134,4335,9,9]
>>>name2 = [453,5435,76575,2132]
>>>name.extend(name2)
>>>print(name)
[32, 23, 21, 52, 14, 546, 7, 68, 76, 98, 5435, 2134, 4335, 9, 9, 453, 5435, 76575, 2132]反转表
>>>name = [32,23,21,52,14,546,7,68,76,98,5435,2134,4335,9,9]
>>>name.reverse()
>>>print(name)
[9, 9, 4335, 2134, 5435, 98, 76, 68, 7, 546, 14, 52, 21, 23, 32]排序表
>>>name = [32,23,21,52,14,546,7,68,76,98,5435,2134,4335,9,9]
>>>name.sort()
>>>print (name)
[7, 9, 9, 14, 21, 23, 32, 52, 68, 76, 98, 546, 2134, 4335, 5435]清空表
>>>name.clear()
>>>print(name)
[]拷贝表
>>>name = [32,23,21,52,14,546,7,68,76,98,5435,2134,4335,9,9]
>>>name3 = name.copy()
>>>name[0] = "Alex"
>>>print(name3)
>>>print(name)
[32, 23, 21, 52, 14, 546, 7, 68, 76, 98, 5435, 2134, 4335, 9, 9]#PS:python 默认只copy第一层,因为copy的内存地址>>>name = [32,23,21,[1321,124314,45654,342],52,14,546,7,68,76,98,5435,2134,4335,9,9]
>>>name3 = name.copy()
>>>name[0] = "Bourbon"
>>>name[3][0] = 11111
>>>print(name3)
>>>print(name)
[32, 23, 21, [11111, 124314, 45654, 342], 52, 14, 546, 7, 68, 76, 98, 5435, 2134, 4335, 9, 9]
['Bourbon', 23, 21, [11111, 124314, 45654, 342], 52, 14, 546, 7, 68, 76, 98, 5435, 2134, 4335, 9, 9]>>>print(id(name[3]),id(name3[3]))
8632520 8632520PS:深度copy的方式 
>>>import copy
>>>name = [32,23,21,[1321,124314,45654,342],52,14,546,7,68,76,98,5435,2134,4335,9,9]
>>>name3 = name.copy()
>>>name4 = copy.deepcopy(name) #深度copy
>>>name[0] = "Bourbon"
>>>name[3][0] = 11111
>>>print(name3)
>>>print(name)
>>>print(name4)
[32, 23, 21, [11111, 124314, 45654, 342], 52, 14, 546, 7, 68, 76, 98, 5435, 2134, 4335, 9, 9]
['Bourbon', 23, 21, [11111, 124314, 45654, 342], 52, 14, 546, 7, 68, 76, 98, 5435, 2134, 4335, 9, 9]
[32, 23, 21, [1321, 124314, 45654, 342], 52, 14, 546, 7, 68, 76, 98, 5435, 2134, 4335, 9, 9]>>>print(id(name[3]),id(name4[3]))
7781128 7780232显示列表的长度
>>>name = [32,23,21,[1321,124314,45654,342],52,14,546,7,68,76,98,5435,2134,4335,9,9]
>>>print(len(name))
16
list

· 查询

a = ['jerry','jacky','jason','bourbon']
print(a.index("jason"))# 输出
2

· 枚举

#枚举函数,打印下表:
a = ['jarry','jacky','bouron']
for index,i in enumerate(a):print(index,i)#输出
0 jerry
1 jacky
2 bouron

元组(不可变列表)

创建元组:

ages = (11,22,33,44,55)或ages = tuple((11,22,33,44,55))

基本操作:

· 索引

· 切片

· 循环

· 长度

· 包含

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

字典(无序)

创建字典:

id_db = {1234567890:{'name':"Tian si han",'age':22,'addr':'changzhou'},9876543210:{'name':'Tian si nuan','age':'23','addr':'changzhou'}}
print(id_db)#输出
{1234567890: {'age': 22, 'addr': 'changzhou', 'name': 'Tian si han'}, 9876543210: {'age': '23', 'addr': 'changzhou', 'name': 'Tian si nuan'}}

常用操作:

· 索引

# 查找 (最安全的获取方法)
print(id_db[1234567890].get('name'))# 输出
Tian si hanprint(id_db[1234567890].get('job'))# 输出
None

· 新增

#添加元素
id_db[1234567890]['qq_num'] = 75298335
print(id_db[1234567890])#输出
{'addr': 'changzhou', 'qq_num': 75298335, 'name': 'Tian si han', 'age': 22}

· 删除

#删除元素
id_db[9876543210].pop("addr")                  
print(id_db[9876543210])#输出
{'name': 'Tian si nuan', 'age': '23'}

· 更改

#更改元素
id_db[9876543210]['name'] = "Tian si leng"
print(id_db[9876543210])#输出
{'age': '23', 'name': 'Tian si leng'}

· 键、值、键值对

· 循环

· 长度

class dict(object):"""dict() -> new empty dictionarydict(mapping) -> new dictionary initialized from a mapping object's(key, value) pairsdict(iterable) -> new dictionary initialized as if via:d = {}for k, v in iterable:d[k] = vdict(**kwargs) -> new dictionary initialized with the name=value pairsin 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. """passdef copy(self): # real signature unknown; restored from __doc__""" 浅拷贝 """""" D.copy() -> a shallow copy of D """pass@staticmethod # known casedef 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."""passdef 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. """passdef 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 Falsedef 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 """passdef iterkeys(self): # real signature unknown; restored from __doc__""" key可迭代 """""" D.iterkeys() -> an iterator over the keys of D """passdef itervalues(self): # real signature unknown; restored from __doc__""" value可迭代 """""" D.itervalues() -> an iterator over the values of D """passdef 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"""passdef popitem(self): # real signature unknown; restored from __doc__""" 获取并在字典中移除 """"""D.popitem() -> (k, v), remove and return some (key, value) pair as a2-tuple; but raise KeyError if D is empty."""passdef 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 """passdef 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] = vIn either case, this is followed by: for k in F: D[k] = F[k]"""passdef 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 """passdef viewkeys(self): # real signature unknown; restored from __doc__""" D.viewkeys() -> a set-like object providing a view on D's keys """passdef viewvalues(self): # real signature unknown; restored from __doc__""" D.viewvalues() -> an object providing a view on D's values """passdef __cmp__(self, y): # real signature unknown; restored from __doc__""" x.__cmp__(y) <==> cmp(x,y) """passdef __contains__(self, k): # real signature unknown; restored from __doc__""" D.__contains__(k) -> True if D has a key k, else False """return Falsedef __delitem__(self, y): # real signature unknown; restored from __doc__""" x.__delitem__(y) <==> del x[y] """passdef __eq__(self, y): # real signature unknown; restored from __doc__""" x.__eq__(y) <==> x==y """passdef __getattribute__(self, name): # real signature unknown; restored from __doc__""" x.__getattribute__('name') <==> x.name """passdef __getitem__(self, y): # real signature unknown; restored from __doc__""" x.__getitem__(y) <==> x[y] """passdef __ge__(self, y): # real signature unknown; restored from __doc__""" x.__ge__(y) <==> x>=y """passdef __gt__(self, y): # real signature unknown; restored from __doc__""" x.__gt__(y) <==> x>y """passdef __init__(self, seq=None, **kwargs): # known special case of dict.__init__"""dict() -> new empty dictionarydict(mapping) -> new dictionary initialized from a mapping object's(key, value) pairsdict(iterable) -> new dictionary initialized as if via:d = {}for k, v in iterable:d[k] = vdict(**kwargs) -> new dictionary initialized with the name=value pairsin the keyword argument list.  For example:  dict(one=1, two=2)# (copied from class doc)"""passdef __iter__(self): # real signature unknown; restored from __doc__""" x.__iter__() <==> iter(x) """passdef __len__(self): # real signature unknown; restored from __doc__""" x.__len__() <==> len(x) """passdef __le__(self, y): # real signature unknown; restored from __doc__""" x.__le__(y) <==> x<=y """passdef __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 """passdef __ne__(self, y): # real signature unknown; restored from __doc__""" x.__ne__(y) <==> x!=y """passdef __repr__(self): # real signature unknown; restored from __doc__""" x.__repr__() <==> repr(x) """passdef __setitem__(self, i, y): # real signature unknown; restored from __doc__""" x.__setitem__(i, y) <==> x[i]=y """passdef __sizeof__(self): # real signature unknown; restored from __doc__""" D.__sizeof__() -> size of D in memory, in bytes """pass__hash__ = Nonedict
dict

PS:循环,range,continue和break

#把字典变成一个元组(列表)    一般不用
print(id_db.items())#输出
dict_items([(1234567890, {'age': 22, 'addr': 'changzhou', 'name': 'Tian si han'}), (9876543210, {'age': '23', 'addr': 'changzhou', 'name': 'Tian si nuan'})])#------------------------------------------------------------------------------------------------#打印字典里所有的vlave        一般不用
print(id_db.values())#输出
dict_values([{'age': 22, 'addr': 'changzhou', 'name': 'Tian si han'}, {'age': '23', 'addr': 'changzhou', 'name': 'Tian si nuan'}])#-----------------------------------------------------------------------------------------------#打印字典里所有的key值
print(id_db.keys())                      #输出
dict_keys([1234567890, 9876543210])#-----------------------------------------------------------------------------------------------
#取一个key,如果存在就输出这个key的值
print(id_db.setdefault(1234567890))            #输出
{'age': 22, 'addr': 'changzhou', 'name': 'Tian si han'}#----------------------------------------------------------------------------------------------#取一个key,如果不存在就设置一个key的值    输出:hahah
print(id_db.setdefault(1345678902,"hahah"))         #输出
hahah#----------------------------------------------------------------------------------------------#随机删除    一般不用
print(id_db.popitem())#输出
(1234567890, {'age': 22, 'addr': 'changzhou', 'name': 'Tian si han'})#----------------------------------------------------------------------------------------------#高效循环
for key in id_db:                           print(key,id_db[key])#输出
1234567890 {'age': 22, 'addr': 'changzhou', 'name': 'Tian si han'}
9876543210 {'age': '23', 'addr': 'changzhou', 'name': 'Tian si nuan'}#----------------------------------------------------------------------------------------------#取值
v = id_db.get(1234567890)
print(v)#输出
{'age': 22, 'addr': 'changzhou', 'name': 'Tian si han'}y = id_db.get(111111111)
print(y)#输出
None#-------------------------------------------------------------------------------------------
dic2 = {'name':"bourbon",1234567890:{'name':"Tian si han",'age':23,'addr':"changzhou"},
}
id_db.update(dic2)
print(id_db)#输出
{1234567890: {'age': 23, 'addr': 'changzhou', 'name': 'Tian si han'}, 9876543210: {'age': '23', 'addr': 'changzhou', 'name': 'Tian si nuan'}, 'name': 'bourbon'}

转载于:https://www.cnblogs.com/Bourbon-tian/p/5892151.html

相关文章:

web项目答辩总结_web实战项目遇到问题总结探索

最近在写一个django的web项目&#xff0c;后端代码基本都已经写好了&#xff0c;主要是前端&#xff0c;以前学过一段前端&#xff0c;只是对一些基本的方法知道&#xff0c;但还有很多东西不熟练&#xff0c;问题是在遇到表单数据时候&#xff0c;如何对参数整体打包发送后端接…

iOS----------计算一段代码执行时间

CFAbsoluteTime start CFAbsoluteTimeGetCurrent(); //在这写入要计算时间的代码 // do something CFAbsoluteTime end CFAbsoluteTimeGetCurrent(); NSLog("%f", end - start);转载于:https://www.cnblogs.com/KiVen2015/p/8926265.html

区块链热度不减 应用风险不容忽视

链客&#xff0c;专为开发者而生&#xff0c;有问必答&#xff01; 此文章来自区块链技术社区&#xff0c;未经允许拒绝转载。 今年来&#xff0c;除了区块链本身之外&#xff0c;越来越多的业内人士也更加关注区块链在金融等方面的应用。 4月2日&#xff0c;由京东金融研究院…

POJ 3258:River Hopscotch (最大化最小值)

【题意】 牛要到河对岸&#xff0c;在与河岸垂直的一条线上&#xff0c;河中有N块石头&#xff0c;给定河岸宽度L&#xff0c;以及每一块石头离牛所在河岸的距离&#xff0c; 现在去掉M块石头&#xff0c;要求去掉M块石头后&#xff0c;剩下的石头之间以及石头与河岸的最小距离…

python获取文本光标_使用python readline时如何获取(并设置)当前bash光标位置?

我可以建议Python curses吗&#xff1f;The curses module provides an interface to the curses library, the de-facto standard for portable advanced terminal handling.While curses is most widely used in the Unix environment, versions are available for DOS, OS/2…

Gridview改变单元格颜色

if (e.Row.RowType DataControlRowType.DataRow) { e.Row.Cells[1].BackColor System.Drawing.Color.Red;//第二列的颜色 }转载于:https://www.cnblogs.com/objectxhy/p/5896970.html

区块链为什么这么热?有这么大热度的原因是什么

链客&#xff0c;专为开发者而生&#xff0c;有问必答&#xff01; 此文章来自区块链技术社区&#xff0c;未经允许拒绝转载。 区块链的热度是超乎想象的。 在上地和西二旗密集的写字楼办公空间里&#xff0c;年轻人三五成群聚在一起&#xff0c;在午饭后或散步或聚在茶水间…

使用nmonchart把.nmon文件转换成html

转载&#xff1a;https://blog.csdn.net/zd470015321/article/details/68923280 我的环境 :centos6.6 下载地址 nmon: http://nmon.sourceforge.net/pmwiki.php?nSite.Download nmon analyzer: https://www.ibm.com/developerworks/community/wikis/home?langen#!/wiki/Power…

java web中文乱码处理笔记

一、发生中文乱码的情况有以下三种&#xff1a; 1.表单form的两种提交出现中文乱码 ① get提交 ② post提交 2.超链接&#xff08;本质是get提交&#xff09;出现中文乱码 3、sendRedirect(发生乱码) 二、乱码产生的原因&#xff1a; 浏览器编码 utf-8 发送请求给服务器是会产…

python websocket 客户端_aiohttp Websocket客户端和HTTP

我正在编写一个应用程序&#xff0c;它需要从两个来源接收事件。有些事件来自Websocket客户机连接&#xff0c;有些来自传入的HTTP请求。aiohttp是否可以在同一个应用程序中同时使用这两个侦听器&#xff0c;还是需要两个单独的可执行文件&#xff1f;在我目前有一个函数&#…

你关注区块链了吗?

链客&#xff0c;专为开发者而生&#xff0c;有问必答&#xff01; 此文章来自区块链技术社区&#xff0c;未经允许拒绝转载。 前言&#xff1a;关于什么是区块链的论述有很多&#xff0c;本文从公共数据库、印刷机、治理、经济学、组织方式等方面进行阐述&#xff0c;作者观点…

(转)记忆杭州中的(非杭户籍人)

非杭州户籍外来人员在杭州 一、为杭州所做的贡献 1.知识分子 科技创新&#xff08;这个很简单明了&#xff0c;现在的国家已经不是八九十年代的国家了&#xff0c;飞速发展的今天离不开一群知识分子&#xff09; 人才培养&#xff08;光谈科技发展&#xff0c;也要有一群人教育…

ProgressDialog的使用-------------范例(学习笔记)

-------------------------------XML------------------------ <?xml version"1.0" encoding"utf-8"?> <LinearLayout xmlns:android"http://schemas.android.com/apk/res/android" xmlns:tools"http://schemas.android.com/too…

python自动化ppt_python自动化怎么操作ppt?

社会的不断进步&#xff0c;科技的不断发展&#xff0c;让每个人都越发趋向自动化的社会&#xff0c;大家有没有想过居然可以在工作软件上也实现自动化&#xff0c;是不是非常神奇呢&#xff1f;请大家在惊叹神奇之余&#xff0c;跟着小编一起来感受下吧~python-pptx模块简介1、…

你不应该关注区块链的“杀手级应用”

链客&#xff0c;专为开发者而生&#xff0c;有问必答&#xff01; 此文章来自区块链技术社区&#xff0c;未经允许拒绝转载。 在每一次区块链大会上&#xff0c;人们无不讨论一个话题&#xff1a;区块链的下一个杀手级应用是什么&#xff1f;下一个获得大规模应用的成功案例是…

项目管理中问题与对策探讨

[摘要]以深圳市东深电子技术有限公司的项目管理现状为基础&#xff0c;剖析该公司在项目管理方面存在的弊端&#xff0c;并提出若干指导性建议。 一、存在问题 深圳市东深电子技术有限公司是一家以水行业计算机监控系统工程项目为主的公司。该公司成立于1997年&#xff0c;经过…

ssm启动报错cannot find class_SSM整合补充 RBAC(权限控制)过滤器

1. 什么是RBAC(1) 请简述什么是RBACRBAC(Role-Based Access Control)基于角色的访问控制RBAC认为权限的过程可以抽象概括为:判断 [Who 是否可以对 What 进行 How的访问操作(Operator)]Who:权限的拥有者或主键What:权限针对的对象或资源How:具体的权限Operator:操作.表明对 What…

EasyPusher实现Android手机屏幕桌面直播,实时推送操作画面,用于手游直播等应用

本文转自EasyDarwin开源团队成员John的博客&#xff1a;http://blog.csdn.net/jyt0551/article/details/52651194由于Android 5.0提供了捕获当前屏幕画面的SDK&#xff0c;基于该SDK&#xff0c;EasyPusher实现了实时推送手机屏幕画面的功能。经测试&#xff0c;效果很不错&…

区块链技术之以太坊ETH白皮书

链客&#xff0c;专为开发者而生&#xff0c;有问必答&#xff01; 此文章来自区块链技术社区&#xff0c;未经允许拒绝转载。 基于中本聪区块链比特币1.0之后&#xff0c;天才少年Vitalik Buterin&#xff08;V神&#xff09;在2013年年末发布了以太坊白皮书&#xff0c;其实…

codevs1137 计算系数

1137 计算系数 2011年NOIP全国联赛提高组 时间限制: 1 s空间限制: 128000 KB题目等级 : 黄金 Gold题解题目描述 Description给定一个多项式(ax by)^k&#xff0c;请求出多项式展开后x^n y^m项的系数。 输入描述 Input Description共一行&#xff0c;包含 5 个整数&#xff0…

选择器优先级_CSS选择器优先级指北

来源&#xff1a;大前端FE(gh_f26dd6c6cfbf)欢迎大家一起来学习前端&#xff0c;期待你加入~相信大部分人刚开始写 css 的时候应该碰到过这样的问题。明明只改了一行样式&#xff0c;然后整个页面就变成了这样↓本文将小节一下 css的优先级&#xff0c;帮助解决碰到的样式重叠 …

区块链膨胀:以太坊客户如何解决存储问题

链客&#xff0c;专为开发者而生&#xff0c;有问必答&#xff01; 此文章来自区块链技术社区&#xff0c;未经允许拒绝转载。 ​​​4,270个代币。27,358笔交易。数字小猫463,713。 以太坊最近举办了很多活动&#xff0c;虽然很多加密爱好者认为这是一个积极的信号&#xff…

Python之路-python(Queue队列、进程、Gevent协程、Select\Poll\Epoll异步IO与事件驱动)

一、进程&#xff1a; 1、语法 2、进程间通讯 3、进程池 二、Gevent协程 三、Select\Poll\Epoll异步IO与事件驱动 一、进程&#xff1a; 1、语法 1 简单的启动线程语法 2 def run(name): 3 time.sleep(2) 4 print("hello",name) 5 6 if __name__ __main__:…

python画圣诞帽_用Python给头像加上圣诞帽

原标题&#xff1a;用Python给头像加上圣诞帽随着圣诞的到来&#xff0c;大家纷纷官微给自己的头像加上一顶圣诞帽。我们有必要写一个程序来做这件事情。用到的工具OpenCVdlib流程一、素材准备首先我们需要准备一个圣诞帽的素材&#xff0c;格式最好为PNG&#xff0c;因为PNG的…

Python知识点进阶——生成器

生成器为什么要将列表转化为迭代器&#xff1f;因为列表太大的话用内存太大&#xff0c;做成迭代器可以节省空间&#xff0c;用的时候再拿出部分。生成器是不会把结果保存在一个系列中&#xff0c;而是保存生成器的状态&#xff0c;在每次进行迭代时返回一个值&#xff0c;知道…

以太坊开启区块链2.0时代

链客&#xff0c;专为开发者而生&#xff0c;有问必答&#xff01; 此文章来自区块链技术社区&#xff0c;未经允许拒绝转载。 今天我们唠唠以太坊&#xff0c;这个开启区块链2.0时代的伟大项目。 前面我们说比特币实际上是一个大账本&#xff0c;从比特币白皮书里走出来的区…

手把手教你架构3d游戏引擎pdf_一个在游戏行业摸爬滚打了十几年的人,为何我对这本书情有独钟...

Big News&#xff01;《游戏开发&#xff1a;世嘉新人培训教材》今日开始预售啦&#xff01;经过漫长的等待&#xff0c;这次终于可以买到了。现在下单&#xff0c;你将在图书出印厂的第一时间收到书哦&#xff5e;这本书由世嘉一线开发者执笔&#xff0c;并被选为世嘉新人培训…

PostgreSQL获取年月日

1.获取当前日期的年份 select to_char(t.detect_date,YYYY) select extract(year from now())为double precision 格式类型select to_char((SELECT now()::timestamp),yyyy) 2.获取下一年select to_char((SELECT now()::timestamp 1 year),yyyy) 3.获取上一年select to_char((S…

查看mysql主外键信息

SELECT *FROMinformation_schema.key_column_usage tWHERE t.constraint_schema 库名称AND t.constraint_name 外键名;转载于:https://www.cnblogs.com/igoodful/p/8954091.html

什么是以太坊,它是区块链2.0的代表,它又什么特点?

链客&#xff0c;专为开发者而生&#xff0c;有问必答&#xff01; 此文章来自区块链技术社区&#xff0c;未经允许拒绝转载。 以太坊 是一种全球共享计算&#xff0c;是各种分散应用程序的基础。它有一个独立于比特币的独立区块链&#xff0c;但与之类似。以太坊的区块链有显…