这篇文章主要介绍python当中用的非常多的一种内置类型——str.它属于python中的Sequnce Type(序列类型).python中一共7种序列类型,分别为str(字符串),unicode(u字符串),list(列表),tuple(元组),bytearray(字节数组),buffer(缓冲内存),xrange(范围).它们的通用操作如下: Operation Result x in s 判断x是否在s中 x not in s 判断x是不在s中 x + t 两个序列合并, 将t加到s之后…
2.1 Built-in Functions The Python interpreter has a number of functions built into it that are always available. They are listed here in alphabetical order. __import__( name[, globals[, locals[, fromlist]]]) This function is invoked by the import sta…
Python中基础数据类型 1.数字 整型a=12或者a=int(2),本质上各种数据类型都可看成是类,声明一个变量时候则是在实例化一个类. 整型具备的功能: 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 gi…
在python中,unicode是内存编码集,一般我们将数据存储到文件时,需要将数据先编码为其他编码集,比如utf-8.gbk等. 读取数据的时候再通过同样的编码集进行解码即可. #python3 >>> s = '中国' >>> a = s.encode() >>> a b'\xe4\xb8\xad\xe5\x9b\xbd' >>> b = a.decode() >>> b '中国' 但是其实还有一种unicode…