熟练掌握python常用数据类型内置方法是每个初学者必须具备的内功。

  下面介绍了python常用的集中数据类型及其方法,点开源代码,其中对主要方法都进行了中文注释。

一、整型

a = 100

a.xxx()

  1. class int(object):
  2.  
  3. def bit_length(self):
  4. ##如果将某个整数用2进制表示,返回这个2进制所占bit位数。
  5. return 0
  6.  
  7. def conjugate(self, *args, **kwargs):
  8. ##共轭复数
  9.  
  10. @classmethod # known case
  11. def from_bytes(cls, bytes, byteorder, *args, **kwargs):
  12. ##好像进制转换有关,傻傻搞不懂,百度也没有答案
  13. pass
  14.  
  15. def to_bytes(self, length, byteorder, *args, **kwargs):
  16. ##上面那个的反向方法
  17. pass
  18.  
  19. def __abs__(self, *args, **kwargs):
  20. ##数学函数:绝对值
  21. """ abs(self) """
  22. pass
  23.  
  24. def __add__(self, *args, **kwargs):
  25. ##加法
  26. """ Return self+value. """
  27. pass
  28.  
  29. def __and__(self, *args, **kwargs):
  30. ##逻辑与运算
  31. """ Return self&value. """
  32. pass
  33.  
  34. def __bool__(self, *args, **kwargs):
  35. ##
  36. """ self != 0 """
  37. pass
  38.  
  39. def __ceil__(self, *args, **kwargs):
  40. """ Ceiling of an Integral returns itself. """
  41. pass
  42.  
  43. def __divmod__(self, *args, **kwargs):
  44. """ Return divmod(self, value). """
  45. pass
  46.  
  47. def __eq__(self, *args, **kwargs):
  48. """ Return self==value. """
  49. pass
  50.  
  51. def __float__(self, *args, **kwargs):
  52. """ float(self) """
  53. pass
  54.  
  55. def __floordiv__(self, *args, **kwargs):
  56. """ Return self//value. """
  57. pass
  58.  
  59. def __floor__(self, *args, **kwargs):
  60. """ Flooring an Integral returns itself. """
  61. pass
  62.  
  63. def __format__(self, *args, **kwargs):
  64. pass
  65.  
  66. def __getattribute__(self, *args, **kwargs):
  67. """ Return getattr(self, name). """
  68. pass
  69.  
  70. def __getnewargs__(self, *args, **kwargs):
  71. pass
  72.  
  73. def __ge__(self, *args, **kwargs):
  74. """ Return self>=value. """
  75. pass
  76.  
  77. def __gt__(self, *args, **kwargs):
  78. """ Return self>value. """
  79. pass
  80.  
  81. def __hash__(self, *args, **kwargs):
  82. """ Return hash(self). """
  83. pass
  84.  
  85. def __index__(self, *args, **kwargs):
  86. """ Return self converted to an integer, if self is suitable for use as an index into a list. """
  87. pass
  88.  
  89. def __init__(self, x, base=10):
  90. ##构造方法,可以指定进制,采用base = 进制数的形式。
  91.  
  92. def __int__(self, *args, **kwargs):
  93. """ int(self) """
  94. pass
  95.  
  96. def __invert__(self, *args, **kwargs):
  97. """ ~self """
  98. pass
  99.  
  100. def __le__(self, *args, **kwargs):
  101. """ Return self<=value. """
  102. pass
  103.  
  104. def __lshift__(self, *args, **kwargs):
  105. """ Return self<<value. """
  106. pass
  107.  
  108. def __lt__(self, *args, **kwargs):
  109. """ Return self<value. """
  110. pass
  111.  
  112. def __mod__(self, *args, **kwargs):
  113. """ Return self%value. """
  114. pass
  115.  
  116. def __mul__(self, *args, **kwargs):
  117. """ Return self*value. """
  118. pass
  119.  
  120. def __neg__(self, *args, **kwargs):
  121. """ -self """
  122. pass
  123.  
  124. @staticmethod # known case of __new__
  125. def __new__(*args, **kwargs):
  126. """ Create and return a new object. See help(type) for accurate signature. """
  127. pass
  128.  
  129. def __ne__(self, *args, **kwargs):
  130. """ Return self!=value. """
  131. pass
  132.  
  133. def __or__(self, *args, **kwargs):
  134. """ Return self|value. """
  135. pass
  136.  
  137. def __pos__(self, *args, **kwargs):
  138. """ +self """
  139. pass
  140.  
  141. def __pow__(self, *args, **kwargs):
  142. """ Return pow(self, value, mod). """
  143. pass
  144.  
  145. def __radd__(self, *args, **kwargs): #
  146. """ Return value+self. """
  147. pass
  148.  
  149. def __rand__(self, *args, **kwargs):
  150. """ Return value&self. """
  151. pass
  152.  
  153. def __rdivmod__(self, *args, **kwargs):
  154. """ Return divmod(value, self). """
  155. pass
  156.  
  157. def __repr__(self, *args, **kwargs):
  158. """ Return repr(self). """
  159. pass
  160.  
  161. def __rfloordiv__(self, *args, **kwargs):
  162. """ Return value//self. """
  163. pass
  164.  
  165. def __rlshift__(self, *args, **kwargs):
  166. """ Return value<<self. """
  167. pass
  168.  
  169. def __rmod__(self, *args, **kwargs):
  170. """ Return value%self. """
  171. pass
  172.  
  173. def __rmul__(self, *args, **kwargs):
  174. """ Return value*self. """
  175. pass
  176.  
  177. def __ror__(self, *args, **kwargs):
  178. """ Return value|self. """
  179. pass
  180.  
  181. def __round__(self, *args, **kwargs):
  182. """
  183. Rounding an Integral returns itself.
  184. Rounding with an ndigits argument also returns an integer.
  185. """
  186. pass
  187.  
  188. def __rpow__(self, *args, **kwargs):
  189. """ Return pow(value, self, mod). """
  190. pass
  191.  
  192. def __rrshift__(self, *args, **kwargs):
  193. ##左移
  194. """ Return value>>self. """
  195. pass
  196.  
  197. def __rshift__(self, *args, **kwargs):
  198. """ Return self>>value. """
  199. pass
  200.  
  201. def __rsub__(self, *args, **kwargs):
  202. """ Return value-self. """
  203. pass
  204.  
  205. def __rtruediv__(self, *args, **kwargs):
  206. """ Return value/self. """
  207. pass
  208.  
  209. def __rxor__(self, *args, **kwargs):
  210. """ Return value^self. """
  211. pass
  212.  
  213. def __sizeof__(self, *args, **kwargs):
  214. """ Returns size in memory, in bytes """
  215. pass
  216.  
  217. def __str__(self, *args, **kwargs):
  218. """ Return str(self). """
  219. pass
  220.  
  221. def __sub__(self, *args, **kwargs):
  222. """ Return self-value. """
  223. pass
  224.  
  225. def __truediv__(self, *args, **kwargs):
  226. """ Return self/value. """
  227. pass
  228.  
  229. def __trunc__(self, *args, **kwargs):
  230. """ Truncating an Integral returns itself. """
  231. pass
  232.  
  233. def __xor__(self, *args, **kwargs):
  234. """ Return self^value. """
  235. pass
  236.  
  237. denominator = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
  238. """the denominator of a rational number in lowest terms"""
  239.  
  240. imag = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
  241. """the imaginary part of a complex number"""
  242.  
  243. numerator = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
  244. """the numerator of a rational number in lowest terms"""
  245.  
  246. real = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
  247. """the real part of a complex number"""

整数

INT类型的内置方法多数为数学运算使用,不需太多记忆,随用随查。

二、浮点型(float)

a = 1.424242

  1. class float(object):
  2.  
  3. def as_integer_ratio(self):
  4. ##将一个浮点数表示为最大近似的两个整数的除,例如1.5可以表示为3/2
  5. pass
  6.  
  7. def conjugate(self, *args, **kwargs):
  8. ##共轭复数
  9. pass
  10.  
  11. def fromhex(self, string):
  12. ##将一个十六进制的字符串转换为浮点数
  13. return 0.0
  14.  
  15. def hex(self):
  16. ##将一个浮点数表示为十六进制的字符串
  17. return ""
  18.  
  19. def is_integer(self, *args, **kwargs):
  20. ##判断某个浮点数是否同时也是整型
  21. pass
  22.  
  23. def __abs__(self, *args, **kwargs):
  24. """ abs(self) """
  25. pass
  26.  
  27. def __add__(self, *args, **kwargs):
  28. """ Return self+value. """
  29. pass
  30.  
  31. def __bool__(self, *args, **kwargs):
  32. """ self != 0 """
  33. pass
  34.  
  35. def __divmod__(self, *args, **kwargs):
  36. """ Return divmod(self, value). """
  37. pass
  38.  
  39. def __eq__(self, *args, **kwargs):
  40. """ Return self==value. """
  41. pass
  42.  
  43. def __float__(self, *args, **kwargs):
  44. """ float(self) """
  45. pass
  46.  
  47. def __floordiv__(self, *args, **kwargs): #
  48. """ Return self//value. """
  49. pass
  50.  
  51. def __format__(self, format_spec):
  52. """
  53. float.__format__(format_spec) -> string
  54.  
  55. Formats the float according to format_spec.
  56. """
  57. return ""
  58.  
  59. def __getattribute__(self, *args, **kwargs):
  60. """ Return getattr(self, name). """
  61. pass
  62.  
  63. def __getformat__(self, typestr):
  64. ##这是一个连python官方都不知道干什么的方法,忘记它吧
  65. return ""
  66.  
  67. def __getnewargs__(self, *args, **kwargs):
  68. pass
  69.  
  70. def __ge__(self, *args, **kwargs):
  71. """ Return self>=value. """
  72. pass
  73.  
  74. def __gt__(self, *args, **kwargs):
  75. """ Return self>value. """
  76. pass
  77.  
  78. def __hash__(self, *args, **kwargs):
  79. """ Return hash(self). """
  80. pass
  81.  
  82. def __init__(self, x):
  83. pass
  84.  
  85. def __int__(self, *args, **kwargs):
  86. """ int(self) """
  87. pass
  88.  
  89. def __le__(self, *args, **kwargs):
  90. """ Return self<=value. """
  91. pass
  92.  
  93. def __lt__(self, *args, **kwargs):
  94. """ Return self<value. """
  95. pass
  96.  
  97. def __mod__(self, *args, **kwargs):
  98. """ Return self%value. """
  99. pass
  100.  
  101. def __mul__(self, *args, **kwargs):
  102. """ Return self*value. """
  103. pass
  104.  
  105. def __neg__(self, *args, **kwargs):
  106. """ -self """
  107. pass
  108.  
  109. @staticmethod
  110. def __new__(*args, **kwargs):
  111. """ Create and return a new object. See help(type) for accurate signature. """
  112. pass
  113.  
  114. def __ne__(self, *args, **kwargs):
  115. """ Return self!=value. """
  116. pass
  117.  
  118. def __pos__(self, *args, **kwargs):
  119. """ +self """
  120. pass
  121.  
  122. def __pow__(self, *args, **kwargs):
  123. """ Return pow(self, value, mod). """
  124. pass
  125.  
  126. def __radd__(self, *args, **kwargs):
  127. """ Return value+self. """
  128. pass
  129.  
  130. def __rdivmod__(self, *args, **kwargs):
  131. """ Return divmod(value, self). """
  132. pass
  133.  
  134. def __repr__(self, *args, **kwargs):
  135. """ Return repr(self). """
  136. pass
  137.  
  138. def __rfloordiv__(self, *args, **kwargs):
  139. """ Return value//self. """
  140. pass
  141.  
  142. def __rmod__(self, *args, **kwargs):
  143. """ Return value%self. """
  144. pass
  145.  
  146. def __rmul__(self, *args, **kwargs):
  147. """ Return value*self. """
  148. pass
  149.  
  150. def __round__(self, *args, **kwargs):
  151. """
  152. Return the Integral closest to x, rounding half toward even.
  153. When an argument is passed, work like built-in round(x, ndigits).
  154. """
  155. pass
  156.  
  157. def __rpow__(self, *args, **kwargs):
  158. """ Return pow(value, self, mod). """
  159. pass
  160.  
  161. def __rsub__(self, *args, **kwargs):
  162. """ Return value-self. """
  163. pass
  164.  
  165. def __rtruediv__(self, *args, **kwargs):
  166. """ Return value/self. """
  167. pass
  168.  
  169. def __setformat__(self, typestr, fmt):
  170. ##不要用这个方法
  171. pass
  172.  
  173. def __str__(self, *args, **kwargs):
  174. """ Return str(self). """
  175. pass
  176.  
  177. def __sub__(self, *args, **kwargs):
  178. """ Return self-value. """
  179. pass
  180.  
  181. def __truediv__(self, *args, **kwargs):
  182. """ Return self/value. """
  183. pass
  184.  
  185. def __trunc__(self, *args, **kwargs):
  186. """ Return the Integral closest to x between 0 and x. """
  187. pass
  188.  
  189. imag = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
  190. """the imaginary part of a complex number"""
  191.  
  192. real = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
  193. """the real part of a complex number"""

float

float和int类似,基本都是数学运算方法,他们都有语法糖,不需要这些冗长的方法。

三、字符串

a = 'hello world'

  1. class str(object):
  2.  
  3. def capitalize(self):
  4. ##首字母大写
  5. return ""
  6.  
  7. def casefold(self):
  8. ##不知道干啥用
  9. return ""
  10.  
  11. def center(self, width, fillchar=None):
  12. ##设定宽度,让字符串打印的时候居中,可以设定填补的字符,例如:
  13. ##———————商品展示—————————
  14. return ""
  15.  
  16. def count(self, sub, start=None, end=None):
  17. ##在字符串中统计子串的个数,可以设定起始和结束位置。
  18. return 0
  19.  
  20. def encode(self, encoding='utf-8', errors='strict'):
  21. ##将字符串编码成指定的编码格式,默认为utf-8
  22. return b""
  23.  
  24. def endswith(self, suffix, start=None, end=None):
  25. ##测试字符串是否以指定的字符串结尾,可以指定判断的起始和结束位置。
  26. return False
  27.  
  28. def expandtabs(self, tabsize=8):
  29. ##将tab转换成空格,默认一个tab转换成8个空格,可以自己指定转换数量。
  30. return ""
  31.  
  32. def find(self, sub, start=None, end=None):
  33. ##查找子串在原字符串中的最近的位置下标,可以指定起始位置。,如果没找到,返回 -1
  34. return 0
  35.  
  36. def format(self, *args, **kwargs):
  37. ##字符串格式化,接收动态参数。例如:
  38. '''
  39. s = 'hello {0},this is {1}'
  40. s.format('andy','jack')
  41. 或者:
  42. s = 'hello {name1},this is {name2}'
  43. s.format(name2='jack',name1='andy')
  44. '''
  45. pass
  46.  
  47. def format_map(self, mapping):
  48. """
  49. S.format_map(mapping) -> str
  50.  
  51. Return a formatted version of S, using substitutions from mapping.
  52. The substitutions are identified by braces ('{' and '}').
  53. """
  54. return ""
  55.  
  56. def index(self, sub, start=None, end=None):
  57. ##和find方法一样也是查找子串的位置。不同的是,如果没找到会跳出异常。
  58. return 0
  59.  
  60. def isalnum(self):
  61. ##测试字符串是否全由数字和字母组成,返回True或False。
  62. return False
  63.  
  64. def isalpha(self):
  65. #测试字符串是否全由字母组成,返回True或False。
  66. return False
  67.  
  68. def isdecimal(self):
  69. ##测试字符串是否全由10进制数字组成,返回True或False。
  70. return False
  71.  
  72. def isdigit(self):
  73. ##测试字符串是否全由数字组成,返回True或False。
  74. return False
  75.  
  76. def isidentifier(self):
  77. ##测试字符串是否由标识符组成,返回True或False。
  78. return False
  79.  
  80. def islower(self):
  81. ##测试字符串是否全由小写字母组成,返回True或False。
  82. return False
  83.  
  84. def isnumeric(self):
  85.  
  86. return False
  87.  
  88. def isprintable(self):
  89. ##判断字符串是否可打印
  90. return False
  91.  
  92. def isspace(self):
  93. ##判断字符串是否为空白
  94. return False
  95.  
  96. def istitle(self):
  97. ##判断字符串是否是标题
  98. return False
  99.  
  100. def isupper(self):
  101. ##判断字符串是否全是大写
  102. return False
  103.  
  104. def join(self, iterable):
  105. ##极为重要的字符串方法,可以将对象的元素连接起来。例如:
  106. ##s = ''.join(['a','b','c'])
  107. ##s = 'abc'
  108. return ""
  109.  
  110. def ljust(self, width, fillchar=None):
  111. ##字符串左对齐的同时,右边用指定的字符填充指定的宽度。
  112. return ""
  113.  
  114. def lower(self):
  115. ##将字符串全部变成小写
  116. return ""
  117.  
  118. def lstrip(self, chars=None):
  119. ##去除字符串左边的东东
  120. return ""
  121.  
  122. def maketrans(self, *args, **kwargs):
  123. ##一个复杂的字符替换方法
  124. pass
  125.  
  126. def partition(self, sep):
  127. ##以某个指定的子串为分割处,将字符串分割成各个部分,并返回一个元组。
  128. pass
  129.  
  130. def replace(self, old, new, count=None):
  131. ##用新的子串替换旧的子串,可以指定数量
  132. return ""
  133.  
  134. def rfind(self, sub, start=None, end=None):
  135. ##从右往左查找子串
  136. return 0
  137.  
  138. def rindex(self, sub, start=None, end=None):
  139. ##从右往左查找子串的下标
  140. return 0
  141.  
  142. def rjust(self, width, fillchar=None):
  143. ##字符串右对齐的同时,左边用指定字符填充指定宽度。
  144. return ""
  145.  
  146. def rpartition(self, sep):
  147. ##从右往左分割字符串
  148. pass
  149.  
  150. def rsplit(self, sep=None, maxsplit=-1):
  151. ##从右往左分割
  152. return []
  153.  
  154. def rstrip(self, chars=None):
  155. ##去除字符串右边的东东
  156. return ""
  157.  
  158. def split(self, sep=None, maxsplit=-1):
  159. ##极为重要的字符串方法。将字符串以指定字符为标志进行分割,默认是空格。返回一个列表。
  160. return []
  161.  
  162. def splitlines(self, keepends=None):
  163. ##以行为单位分割字符串
  164. return []
  165.  
  166. def startswith(self, prefix, start=None, end=None):
  167. ##判断字符串是否由指定的子串开始,可以指定起始位置。
  168. return False
  169.  
  170. def strip(self, chars=None):
  171. ##极为重要的字符串方法,将字符串的前后指定字符去除,默认是去空格和换行符。
  172. return ""
  173.  
  174. def swapcase(self):
  175. ##字符串大小写反转
  176. return ""
  177.  
  178. def title(self):
  179. ##将字符串转换成标题格式
  180. return ""
  181.  
  182. def translate(self, table):
  183. '''
  184. 借用武神的例子:
  185. 转换,与上面的maketrans方法配合,需要先做一个对应表,
  186. 最后一个表示删除字符集合
  187. intab = "aeiou"
  188. outtab = "12345"
  189. trantab = maketrans(intab, outtab)
  190. str = "this is string example....wow!!!"
  191. print str.translate(trantab, 'xm')
  192. '''
  193. return ""
  194.  
  195. def upper(self):
  196. ##将字符串全部转换成大写
  197. return ""
  198.  
  199. def zfill(self, width):
  200. ##返回指定长度的字符串,原字符串右对齐,前面填充0
  201. return ""
  202.  
  203. def __add__(self, *args, **kwargs): # real signature unknown
  204. """ Return self+value. """
  205. pass
  206.  
  207. def __contains__(self, *args, **kwargs): # real signature unknown
  208. """ Return key in self. """
  209. pass
  210.  
  211. def __eq__(self, *args, **kwargs): # real signature unknown
  212. """ Return self==value. """
  213. pass
  214.  
  215. def __format__(self, format_spec): # real signature unknown; restored from __doc__
  216. """
  217. S.__format__(format_spec) -> str
  218.  
  219. Return a formatted version of S as described by format_spec.
  220. """
  221. return ""
  222.  
  223. def __getattribute__(self, *args, **kwargs): # real signature unknown
  224. """ Return getattr(self, name). """
  225. pass
  226.  
  227. def __getitem__(self, *args, **kwargs): # real signature unknown
  228. """ Return self[key]. """
  229. pass
  230.  
  231. def __getnewargs__(self, *args, **kwargs): # real signature unknown
  232. pass
  233.  
  234. def __ge__(self, *args, **kwargs): # real signature unknown
  235. """ Return self>=value. """
  236. pass
  237.  
  238. def __gt__(self, *args, **kwargs): # real signature unknown
  239. """ Return self>value. """
  240. pass
  241.  
  242. def __hash__(self, *args, **kwargs):
  243. """ Return hash(self). """
  244. pass
  245.  
  246. def __init__(self, value='', encoding=None, errors='strict'):
  247. ##字符串构造方法
  248. """
  249. str(object='') -> str
  250. str(bytes_or_buffer[, encoding[, errors]]) -> str
  251.  
  252. Create a new string object from the given object. If encoding or
  253. errors is specified, then the object must expose a data buffer
  254. that will be decoded using the given encoding and error handler.
  255. Otherwise, returns the result of object.__str__() (if defined)
  256. or repr(object).
  257. encoding defaults to sys.getdefaultencoding().
  258. errors defaults to 'strict'.
  259. # (copied from class doc)
  260. """
  261. pass
  262.  
  263. def __iter__(self, *args, **kwargs): # real signature unknown
  264. """ Implement iter(self). """
  265. pass
  266.  
  267. def __len__(self, *args, **kwargs): # real signature unknown
  268. """ Return len(self). """
  269. pass
  270.  
  271. def __le__(self, *args, **kwargs): # real signature unknown
  272. """ Return self<=value. """
  273. pass
  274.  
  275. def __lt__(self, *args, **kwargs): # real signature unknown
  276. """ Return self<value. """
  277. pass
  278.  
  279. def __mod__(self, *args, **kwargs): # real signature unknown
  280. """ Return self%value. """
  281. pass
  282.  
  283. def __mul__(self, *args, **kwargs): # real signature unknown
  284. """ Return self*value.n """
  285. pass
  286.  
  287. @staticmethod # known case of __new__
  288. def __new__(*args, **kwargs): # real signature unknown
  289. """ Create and return a new object. See help(type) for accurate signature. """
  290. pass
  291.  
  292. def __ne__(self, *args, **kwargs): # real signature unknown
  293. """ Return self!=value. """
  294. pass
  295.  
  296. def __repr__(self, *args, **kwargs): # real signature unknown
  297. """ Return repr(self). """
  298. pass
  299.  
  300. def __rmod__(self, *args, **kwargs): # real signature unknown
  301. """ Return value%self. """
  302. pass
  303.  
  304. def __rmul__(self, *args, **kwargs): # real signature unknown
  305. """ Return self*value. """
  306. pass
  307.  
  308. def __sizeof__(self): # real signature unknown; restored from __doc__
  309. """ S.__sizeof__() -> size of S in memory, in bytes """
  310. pass
  311.  
  312. def __str__(self, *args, **kwargs): # real signature unknown
  313. """ Return str(self). """
  314. pass

字符串的方法

  对于字符串而言,最重要的方法莫过于index    split   join   strip     replace   center    isdigit   count   find   formate   encode 这几个了。字符串如果用得得心应手,那么python数据结构的三分之一你就掌握了。

四、字节类型(byte)

  在Python3以后,字符串和字节类型彻底分开了。两者的区别简单的理解就是:字符串是以字符为单位进行处理的,字节类型是以字节为单位处理的。

  两者在内置方法上几乎一模一样,在使用上只需注意处理的单位不一样即可。

  创建方法:a = bytes('string',encoding='编码类型')

  1. class bytes(object):
  2. """
  3. bytes(iterable_of_ints) -> bytes
  4. bytes(string, encoding[, errors]) -> bytes
  5. bytes(bytes_or_buffer) -> immutable copy of bytes_or_buffer
  6. bytes(int) -> bytes object of size given by the parameter initialized with null bytes
  7. bytes() -> empty bytes object
  8.  
  9. Construct an immutable array of bytes from:
  10. - an iterable yielding integers in range(256)
  11. - a text string encoded using the specified encoding
  12. - any object implementing the buffer API.
  13. - an integer
  14. """
  15. def capitalize(self):
  16. # 首字母大写
  17. pass
  18.  
  19. def center(self, width, fillchar=None):
  20. # 字节居中,两侧填充
  21. pass
  22.  
  23. def count(self, sub, start=None, end=None):
  24. # 统计个数
  25. return 0
  26.  
  27. def decode(self, *args, **kwargs):
  28. # 解码
  29. """
  30. Decode the bytes using the codec registered for encoding.
  31.  
  32. encoding
  33. The encoding with which to decode the bytes.
  34. errors
  35. The error handling scheme to use for the handling of decoding errors.
  36. The default is 'strict' meaning that decoding errors raise a
  37. UnicodeDecodeError. Other possible values are 'ignore' and 'replace'
  38. as well as any other name registered with codecs.register_error that
  39. can handle UnicodeDecodeErrors.
  40. """
  41. pass
  42.  
  43. def endswith(self, suffix, start=None, end=None):
  44. # 判断是否由子串结尾
  45. return False
  46.  
  47. def expandtabs(self, tabsize=8):
  48. # 替换制表符为空格
  49. pass
  50.  
  51. def find(self, sub, start=None, end=None):
  52. # 查找子串
  53. return 0
  54.  
  55. @classmethod # known case
  56. def fromhex(cls, *args, **kwargs):
  57. # 由十六进制转换过来
  58. pass
  59.  
  60. def hex(self):
  61. # 转换为16进制
  62. return ""
  63.  
  64. def index(self, sub, start=None, end=None):
  65. # 查找下标
  66. return 0
  67.  
  68. def isalnum(self):
  69. # 是否都由字母和数字组成
  70. return False
  71.  
  72. def isalpha(self):
  73. # 判断是否都由字母组成
  74. return False
  75.  
  76. def isdigit(self):
  77. # 判断是否都由数字组成
  78. return False
  79.  
  80. def islower(self):
  81. # 小写判断
  82. return False
  83.  
  84. def isspace(self):
  85. # 空格判断
  86. return False
  87.  
  88. def istitle(self):
  89. # 标题判断
  90. return False
  91.  
  92. def isupper(self):
  93. #大写判断
  94. return False
  95.  
  96. def join(self, *args, **kwargs):
  97. # 拼接字节
  98. pass
  99.  
  100. def ljust(self, width, fillchar=None):
  101. # 左对齐
  102. pass
  103.  
  104. def lower(self):
  105.  
  106. # 全部转换为小写
  107. pass
  108.  
  109. def lstrip(self, *args, **kwargs):
  110. # 左边去空格或指定的字符
  111. pass
  112.  
  113. @staticmethod # known case
  114. def maketrans(*args, **kwargs):
  115. # 与另外一个方法配合,转换字节
  116. pass
  117.  
  118. def partition(self, *args, **kwargs):
  119. # 分割字节
  120. pass
  121.  
  122. def replace(self, *args, **kwargs):
  123. # 替换字节内容
  124. pass
  125.  
  126. def rfind(self, sub, start=None, end=None):
  127. # 从右开始查找子串
  128. return 0
  129.  
  130. def rindex(self, sub, start=None, end=None):
  131. # 从右开始查找下标
  132. return 0
  133.  
  134. def rjust(self, width, fillchar=None):
  135. # 右对齐
  136. pass
  137.  
  138. def rpartition(self, *args, **kwargs):
  139. # 从右开始分部
  140. pass
  141.  
  142. def rsplit(self, *args, **kwargs):
  143. # 从右开始分割
  144. pass
  145.  
  146. def rstrip(self, *args, **kwargs):
  147. # 脱去字节右边的空格或指定字符
  148. pass
  149.  
  150. def split(self, *args, **kwargs):
  151. # 分割字符
  152. pass
  153.  
  154. def splitlines(self, *args, **kwargs):
  155. # 按行分割
  156. pass
  157.  
  158. def startswith(self, prefix, start=None, end=None):
  159. # 判断是否由子串开始
  160. return False
  161.  
  162. def strip(self, *args, **kwargs):
  163. # 脱去左右两侧的空格或指定字节
  164. pass
  165.  
  166. def swapcase(self):
  167. # 大小写转换
  168. pass
  169.  
  170. def title(self):
  171. # 设置为标题
  172. pass
  173.  
  174. def translate(self, table, deletechars=None):
  175. # 转换
  176. pass
  177.  
  178. def upper(self):
  179. # 全部大写
  180. pass
  181.  
  182. def zfill(self, width): # real signature unknown; restored from __doc__
  183. """
  184. B.zfill(width) -> copy of B
  185.  
  186. Pad a numeric string B with zeros on the left, to fill a field
  187. of the specified width. B is never truncated.
  188. """
  189. pass
  190.  
  191. def __add__(self, *args, **kwargs): # real signature unknown
  192. """ Return self+value. """
  193. pass
  194.  
  195. def __contains__(self, *args, **kwargs): # real signature unknown
  196. """ Return key in self. """
  197. pass
  198.  
  199. def __eq__(self, *args, **kwargs): # real signature unknown
  200. """ Return self==value. """
  201. pass
  202.  
  203. def __getattribute__(self, *args, **kwargs): # real signature unknown
  204. """ Return getattr(self, name). """
  205. pass
  206.  
  207. def __getitem__(self, *args, **kwargs): # real signature unknown
  208. """ Return self[key]. """
  209. pass
  210.  
  211. def __getnewargs__(self, *args, **kwargs): # real signature unknown
  212. pass
  213.  
  214. def __ge__(self, *args, **kwargs): # real signature unknown
  215. """ Return self>=value. """
  216. pass
  217.  
  218. def __gt__(self, *args, **kwargs): # real signature unknown
  219. """ Return self>value. """
  220. pass
  221.  
  222. def __hash__(self, *args, **kwargs): # real signature unknown
  223. """ Return hash(self). """
  224. pass
  225.  
  226. def __init__(self, value=b'', encoding=None, errors='strict'): # known special case of bytes.__init__
  227. """
  228. bytes(iterable_of_ints) -> bytes
  229. bytes(string, encoding[, errors]) -> bytes
  230. bytes(bytes_or_buffer) -> immutable copy of bytes_or_buffer
  231. bytes(int) -> bytes object of size given by the parameter initialized with null bytes
  232. bytes() -> empty bytes object
  233.  
  234. Construct an immutable array of bytes from:
  235. - an iterable yielding integers in range(256)
  236. - a text string encoded using the specified encoding
  237. - any object implementing the buffer API.
  238. - an integer
  239. # (copied from class doc)
  240. """
  241. pass
  242.  
  243. def __iter__(self, *args, **kwargs): # real signature unknown
  244. """ Implement iter(self). """
  245. pass
  246.  
  247. def __len__(self, *args, **kwargs): # real signature unknown
  248. """ Return len(self). """
  249. pass
  250.  
  251. def __le__(self, *args, **kwargs): # real signature unknown
  252. """ Return self<=value. """
  253. pass
  254.  
  255. def __lt__(self, *args, **kwargs): # real signature unknown
  256. """ Return self<value. """
  257. pass
  258.  
  259. def __mod__(self, *args, **kwargs): # real signature unknown
  260. """ Return self%value. """
  261. pass
  262.  
  263. def __mul__(self, *args, **kwargs): # real signature unknown
  264. """ Return self*value.n """
  265. pass
  266.  
  267. @staticmethod # known case of __new__
  268. def __new__(*args, **kwargs): # real signature unknown
  269. """ Create and return a new object. See help(type) for accurate signature. """
  270. pass
  271.  
  272. def __ne__(self, *args, **kwargs): # real signature unknown
  273. """ Return self!=value. """
  274. pass
  275.  
  276. def __repr__(self, *args, **kwargs): # real signature unknown
  277. """ Return repr(self). """
  278. pass
  279.  
  280. def __rmod__(self, *args, **kwargs): # real signature unknown
  281. """ Return value%self. """
  282. pass
  283.  
  284. def __rmul__(self, *args, **kwargs): # real signature unknown
  285. """ Return self*value. """
  286. pass
  287.  
  288. def __str__(self, *args, **kwargs): # real signature unknown
  289. """ Return str(self). """
  290. pass

byte

五、列表(list)

  Python的列表在其他的语言一般称为数组,它是一个有序可重复的元素集合,可嵌套、可迭代、可修改、可分片、可追加、可删除,因此它的内置方法很多。

  创建方式:li1 = [1,2,3,4]或li = []或li = list(xxx)

  1. class list(object):
  2.  
  3. def append(self, p_object):
  4. # 在列表的最后添加一个元素
  5. pass
  6.  
  7. def clear(self):
  8. # 清空列表内的所有元素
  9. pass
  10.  
  11. def copy(self):
  12. # 列表的浅拷贝
  13. return []
  14.  
  15. def count(self, value):
  16. # 统计某个元素在列表内的个数
  17. return 0
  18.  
  19. def extend(self, iterable):
  20. # 从某个迭代器内获取元素并添加到列表内
  21. pass
  22.  
  23. def index(self, value, start=None, stop=None):
  24. # 找出第一个匹配的元素的下标,如果列表内没有该元素,触发异常。可以设置
  25. # 搜索的起始和结束范围
  26. return 0
  27.  
  28. def insert(self, index, p_object):
  29. # 在指定的下标之前插入元素
  30. pass
  31.  
  32. def pop(self, index=None):
  33. # 删除指定下标的元素(默认是最后1个元素),并将这个元素作为返回值。
  34. # 如果列表为空或者下标超出范围,触发异常。
  35. pass
  36.  
  37. def remove(self, value):
  38. # 删除列表内第一个匹配的元素,如果元素不存在则触发异常。
  39. pass
  40.  
  41. def reverse(self):
  42. # 反转列表的顺序
  43. pass
  44.  
  45. def sort(self, key=None, reverse=False):
  46. # 对列表内的元素进行排序,可指定排序关键字,可指定是否逆序
  47. pass
  48. # 以下为内部方法
  49. def __add__(self, *args, **kwargs): # real signature unknown
  50. """ Return self+value. """
  51. pass
  52.  
  53. def __contains__(self, *args, **kwargs): # real signature unknown
  54. """ Return key in self. """
  55. pass
  56.  
  57. def __delitem__(self, *args, **kwargs): # real signature unknown
  58. """ Delete self[key]. """
  59. pass
  60.  
  61. def __eq__(self, *args, **kwargs): # real signature unknown
  62. """ Return self==value. """
  63. pass
  64.  
  65. def __getattribute__(self, *args, **kwargs): # real signature unknown
  66. """ Return getattr(self, name). """
  67. pass
  68.  
  69. def __getitem__(self, y): # real signature unknown; restored from __doc__
  70. """ x.__getitem__(y) <==> x[y] """
  71. pass
  72.  
  73. def __ge__(self, *args, **kwargs): # real signature unknown
  74. """ Return self>=value. """
  75. pass
  76.  
  77. def __gt__(self, *args, **kwargs): # real signature unknown
  78. """ Return self>value. """
  79. pass
  80.  
  81. def __iadd__(self, *args, **kwargs): # real signature unknown
  82. """ Implement self+=value. """
  83. pass
  84.  
  85. def __imul__(self, *args, **kwargs): # real signature unknown
  86. """ Implement self*=value. """
  87. pass
  88.  
  89. def __init__(self, seq=()): # known special case of list.__init__
  90. """
  91. list() -> new empty list
  92. list(iterable) -> new list initialized from iterable's items
  93. # (copied from class doc)
  94. """
  95. pass
  96.  
  97. def __iter__(self, *args, **kwargs): # real signature unknown
  98. """ Implement iter(self). """
  99. pass
  100.  
  101. def __len__(self, *args, **kwargs): # real signature unknown
  102. """ Return len(self). """
  103. pass
  104.  
  105. def __le__(self, *args, **kwargs): # real signature unknown
  106. """ Return self<=value. """
  107. pass
  108.  
  109. def __lt__(self, *args, **kwargs): # real signature unknown
  110. """ Return self<value. """
  111. pass
  112.  
  113. def __mul__(self, *args, **kwargs): # real signature unknown
  114. """ Return self*value.n """
  115. pass
  116.  
  117. @staticmethod # known case of __new__
  118. def __new__(*args, **kwargs): # real signature unknown
  119. """ Create and return a new object. See help(type) for accurate signature. """
  120. pass
  121.  
  122. def __ne__(self, *args, **kwargs): # real signature unknown
  123. """ Return self!=value. """
  124. pass
  125.  
  126. def __repr__(self, *args, **kwargs): # real signature unknown
  127. """ Return repr(self). """
  128. pass
  129.  
  130. def __reversed__(self): # real signature unknown; restored from __doc__
  131. """ L.__reversed__() -- return a reverse iterator over the list """
  132. pass
  133.  
  134. def __rmul__(self, *args, **kwargs): # real signature unknown
  135. """ Return self*value. """
  136. pass
  137.  
  138. def __setitem__(self, *args, **kwargs): # real signature unknown
  139. """ Set self[key] to value. """
  140. pass
  141.  
  142. def __sizeof__(self): # real signature unknown; restored from __doc__
  143. """ L.__sizeof__() -- size of L in memory, in bytes """
  144. pass
  145.  
  146. __hash__ = None

list

  列表除了内置方法,经常性的操作还有分片,循环等等,使用方法灵活多变。

六、元组(tuple)

  元组是有序可重复,但不可修改的元素集合,内置方法较少,通常用于储存一些固定的值。

  创建方式: tup = ()或tup = (1,2)或tup = tuple(xxx)。特别需要注意的是,如果元组只有1个元素,则要写成(a,)的形式,要在最后加个逗号。

  1. class tuple(object):
  2.  
  3. def count(self, value):
  4. # 统计某个元素在元组内出现的次数
  5. return 0
  6.  
  7. def index(self, value, start=None, stop=None):
  8. # 查找第一个匹配到的元素的下标,可以设置查找起始位置。
  9. # 如果没找到,会触发异常
  10. return 0
  11. # 以下为内置方法
  12. def __add__(self, *args, **kwargs): # real signature unknown
  13. """ Return self+value. """
  14. pass
  15.  
  16. def __contains__(self, *args, **kwargs): # real signature unknown
  17. """ Return key in self. """
  18. pass
  19.  
  20. def __eq__(self, *args, **kwargs): # real signature unknown
  21. """ Return self==value. """
  22. pass
  23.  
  24. def __getattribute__(self, *args, **kwargs): # real signature unknown
  25. """ Return getattr(self, name). """
  26. pass
  27.  
  28. def __getitem__(self, *args, **kwargs): # real signature unknown
  29. """ Return self[key]. """
  30. pass
  31.  
  32. def __getnewargs__(self, *args, **kwargs): # real signature unknown
  33. pass
  34.  
  35. def __ge__(self, *args, **kwargs): # real signature unknown
  36. """ Return self>=value. """
  37. pass
  38.  
  39. def __gt__(self, *args, **kwargs): # real signature unknown
  40. """ Return self>value. """
  41. pass
  42.  
  43. def __hash__(self, *args, **kwargs): # real signature unknown
  44. """ Return hash(self). """
  45. pass
  46.  
  47. def __init__(self, seq=()): # known special case of tuple.__init__
  48. """
  49. tuple() -> empty tuple
  50. tuple(iterable) -> tuple initialized from iterable's items
  51.  
  52. If the argument is a tuple, the return value is the same object.
  53. # (copied from class doc)
  54. """
  55. pass
  56.  
  57. def __iter__(self, *args, **kwargs): # real signature unknown
  58. """ Implement iter(self). """
  59. pass
  60.  
  61. def __len__(self, *args, **kwargs): # real signature unknown
  62. """ Return len(self). """
  63. pass
  64.  
  65. def __le__(self, *args, **kwargs): # real signature unknown
  66. """ Return self<=value. """
  67. pass
  68.  
  69. def __lt__(self, *args, **kwargs): # real signature unknown
  70. """ Return self<value. """
  71. pass
  72.  
  73. def __mul__(self, *args, **kwargs): # real signature unknown
  74. """ Return self*value.n """
  75. pass
  76.  
  77. @staticmethod # known case of __new__
  78. def __new__(*args, **kwargs): # real signature unknown
  79. """ Create and return a new object. See help(type) for accurate signature. """
  80. pass
  81.  
  82. def __ne__(self, *args, **kwargs): # real signature unknown
  83. """ Return self!=value. """
  84. pass
  85.  
  86. def __repr__(self, *args, **kwargs): # real signature unknown
  87. """ Return repr(self). """
  88. pass
  89.  
  90. def __rmul__(self, *args, **kwargs): # real signature unknown
  91. """ Return self*value. """
  92. pass

tuple

七、字典(dict)

  字典是无序的,不可重复的键值对的集合。其键必须为不可修改的类型,不能是列表或字典,通常用字符串做键,而其键值则可以为任意类型。

  创建方法:dic = {}或dic = {"k1":"v1"}或dic = dict(iterator)

  1. class dict(object):
  2.  
  3. def clear(self):
  4. # 删除字典中的所有元素
  5. pass
  6.  
  7. def copy(self):
  8. # 字典的浅拷贝
  9. pass
  10.  
  11. @staticmethod
  12. def fromkeys(*args, **kwargs):
  13. # 从迭代器中获取键值对用于生成字典
  14. pass
  15.  
  16. def get(self, k, d=None):
  17. # 获取字典中某个键的值。如果该键不存在,不会触发异常。
  18. pass
  19.  
  20. def items(self):
  21. # 字典所有键值对的组合
  22. pass
  23.  
  24. def keys(self):
  25. # 字典中所有键的集合
  26. pass
  27.  
  28. def pop(self, k, d=None):
  29. # 删除指定的键,并返回它,如果该键不存在,触发异常
  30. pass
  31.  
  32. def popitem(self):
  33. # 随机删除键值对,并返回它
  34. pass
  35.  
  36. def setdefault(self, k, d=None):
  37. # 如果key不存在,则创建,如果存在,则返回已存在的值且不修改
  38. pass
  39.  
  40. def update(self, E=None, **F):
  41. # 用某个新的字典或迭代器来更新当前的字典。如果新字典的键在
  42. # 旧的字典中不存在,则直接添加进去;如果新字典的键在旧的字典中
  43. # 已经存在,则用新的键值去覆盖,注意是覆盖旧的键值,旧的键值中的数据
  44. # 结构等等都将发生变化,这个过程是重写而不是融合。
  45. pass
  46.  
  47. def values(self):
  48. # 字典中的键值的集合
  49. pass
  50.  
  51. def __contains__(self, *args, **kwargs): # real signature unknown
  52. """ True if D has a key k, else False. """
  53. pass
  54.  
  55. def __delitem__(self, *args, **kwargs): # real signature unknown
  56. """ Delete self[key]. """
  57. pass
  58.  
  59. def __eq__(self, *args, **kwargs): # real signature unknown
  60. """ Return self==value. """
  61. pass
  62.  
  63. def __getattribute__(self, *args, **kwargs): # real signature unknown
  64. """ Return getattr(self, name). """
  65. pass
  66.  
  67. def __getitem__(self, y): # real signature unknown; restored from __doc__
  68. """ x.__getitem__(y) <==> x[y] """
  69. pass
  70.  
  71. def __ge__(self, *args, **kwargs): # real signature unknown
  72. """ Return self>=value. """
  73. pass
  74.  
  75. def __gt__(self, *args, **kwargs): # real signature unknown
  76. """ Return self>value. """
  77. pass
  78.  
  79. def __init__(self, seq=None, **kwargs): # known special case of dict.__init__
  80. """
  81. dict() -> new empty dictionary
  82. dict(mapping) -> new dictionary initialized from a mapping object's
  83. (key, value) pairs
  84. dict(iterable) -> new dictionary initialized as if via:
  85. d = {}
  86. for k, v in iterable:
  87. d[k] = v
  88. dict(**kwargs) -> new dictionary initialized with the name=value pairs
  89. in the keyword argument list. For example: dict(one=1, two=2)
  90. # (copied from class doc)
  91. """
  92. pass
  93.  
  94. def __iter__(self, *args, **kwargs): # real signature unknown
  95. """ Implement iter(self). """
  96. pass
  97.  
  98. def __len__(self, *args, **kwargs): # real signature unknown
  99. """ Return len(self). """
  100. pass
  101.  
  102. def __le__(self, *args, **kwargs): # real signature unknown
  103. """ Return self<=value. """
  104. pass
  105.  
  106. def __lt__(self, *args, **kwargs): # real signature unknown
  107. """ Return self<value. """
  108. pass
  109.  
  110. @staticmethod # known case of __new__
  111. def __new__(*args, **kwargs): # real signature unknown
  112. """ Create and return a new object. See help(type) for accurate signature. """
  113. pass
  114.  
  115. def __ne__(self, *args, **kwargs): # real signature unknown
  116. """ Return self!=value. """
  117. pass
  118.  
  119. def __repr__(self, *args, **kwargs): # real signature unknown
  120. """ Return repr(self). """
  121. pass
  122.  
  123. def __setitem__(self, *args, **kwargs): # real signature unknown
  124. """ Set self[key] to value. """
  125. pass
  126.  
  127. def __sizeof__(self): # real signature unknown; restored from __doc__
  128. """ D.__sizeof__() -> size of D in memory, in bytes """
  129. pass
  130.  
  131. __hash__ = None

dict

八、集合(SET)

  python中的集合是无序,不重复的元素集合
  创建方法:
    se1 = {'123','ab'}
    se2 = set('123','ab')

  注意了:s = {}默认的是创建空的字典,不是创建集合。

  1. class set(object):
  2.  
  3. def add(self, *args, **kwargs):
  4. #为集合增加元素
  5. pass
  6.  
  7. def clear(self, *args, **kwargs):
  8. ##清空集合
  9. pass
  10.  
  11. def copy(self, *args, **kwargs):
  12. ##浅拷贝一个集合
  13. pass
  14.  
  15. def difference(self, *args, **kwargs):
  16. ##求差集。a中存在,b中不存在 ,数学符号为减号-。
  17. ##a.difference(b)或set(a) - set(b)
  18. pass
  19.  
  20. def difference_update(self, *args, **kwargs):
  21. ##求差集,并更新。
  22. ##方法后面带有update的是将求得的结果更新原来的集合
  23. pass
  24.  
  25. def discard(self, *args, **kwargs):
  26. ##移除指定元素,但不报错,不弹出异常。
  27. pass
  28.  
  29. def intersection(self, *args, **kwargs):
  30. ##求交集,数学符号为&。
  31. pass
  32.  
  33. def intersection_update(self, *args, **kwargs):
  34. ##求交集,并更新。
  35. pass
  36.  
  37. def isdisjoint(self, *args, **kwargs):
  38. ##如果两个集合没有交集,那么返回True,否则False
  39. pass
  40.  
  41. def issubset(self, *args, **kwargs):
  42. ##判断是否是子集
  43. pass
  44.  
  45. def issuperset(self, *args, **kwargs):
  46. ##判断是否是父集
  47. pass
  48.  
  49. def pop(self, *args, **kwargs):
  50. ##随机删除一个元素,并返回此元素,慎用。
  51. pass
  52.  
  53. def remove(self, *args, **kwargs):
  54. ##删除指定元素,元素不存在会报出异常
  55. pass
  56.  
  57. def symmetric_difference(self, *args, **kwargs):
  58. ##(a中存在,b中不存在)与(a中不存在,b中存在),也就是对称差集
  59. pass
  60.  
  61. def symmetric_difference_update(self, *args, **kwargs):
  62. ##对称差集,更新
  63. pass
  64.  
  65. def union(self, *args, **kwargs):
  66. ##求并集,数学符号|
  67. pass
  68.  
  69. def update(self, *args, **kwargs):
  70. ##接受一个迭代器,并用它更新集合
  71. pass
  72. ##以下是内部方法,基本不用。
  73. def __and__(self, *args, **kwargs): # real signature unknown
  74. """ Return self&value. """
  75. pass
  76.  
  77. def __contains__(self, y): # real signature unknown; restored from __doc__
  78. """ x.__contains__(y) <==> y in x. """
  79. pass
  80.  
  81. def __eq__(self, *args, **kwargs): # real signature unknown
  82. """ Return self==value. """
  83. pass
  84.  
  85. def __getattribute__(self, *args, **kwargs): # real signature unknown
  86. """ Return getattr(self, name). """
  87. pass
  88.  
  89. def __ge__(self, *args, **kwargs): # real signature unknown
  90. """ Return self>=value. """
  91. pass
  92.  
  93. def __gt__(self, *args, **kwargs): # real signature unknown
  94. """ Return self>value. """
  95. pass
  96.  
  97. def __iand__(self, *args, **kwargs): # real signature unknown
  98. """ Return self&=value. """
  99. pass
  100.  
  101. def __init__(self, seq=()): # known special case of set.__init__
  102. """
  103. set() -> new empty set object
  104. set(iterable) -> new set object
  105.  
  106. Build an unordered collection of unique elements.
  107. # (copied from class doc)
  108. """
  109. pass
  110.  
  111. def __ior__(self, *args, **kwargs): # real signature unknown
  112. """ Return self|=value. """
  113. pass
  114.  
  115. def __isub__(self, *args, **kwargs): # real signature unknown
  116. """ Return self-=value. """
  117. pass
  118.  
  119. def __iter__(self, *args, **kwargs): # real signature unknown
  120. """ Implement iter(self). """
  121. pass
  122.  
  123. def __ixor__(self, *args, **kwargs): # real signature unknown
  124. """ Return self^=value. """
  125. pass
  126.  
  127. def __len__(self, *args, **kwargs): # real signature unknown
  128. """ Return len(self). """
  129. pass
  130.  
  131. def __le__(self, *args, **kwargs): # real signature unknown
  132. """ Return self<=value. """
  133. pass
  134.  
  135. def __lt__(self, *args, **kwargs): # real signature unknown
  136. """ Return self<value. """
  137. pass
  138.  
  139. @staticmethod # known case of __new__
  140. def __new__(*args, **kwargs): # real signature unknown
  141. """ Create and return a new object. See help(type) for accurate signature. """
  142. pass
  143.  
  144. def __ne__(self, *args, **kwargs): # real signature unknown
  145. """ Return self!=value. """
  146. pass
  147.  
  148. def __or__(self, *args, **kwargs): # real signature unknown
  149. """ Return self|value. """
  150. pass
  151.  
  152. def __rand__(self, *args, **kwargs): # real signature unknown
  153. """ Return value&self. """
  154. pass
  155.  
  156. def __reduce__(self, *args, **kwargs): # real signature unknown
  157. """ Return state information for pickling. """
  158. pass
  159.  
  160. def __repr__(self, *args, **kwargs): # real signature unknown
  161. """ Return repr(self). """
  162. pass
  163.  
  164. def __ror__(self, *args, **kwargs): # real signature unknown
  165. """ Return value|self. """
  166. pass
  167.  
  168. def __rsub__(self, *args, **kwargs): # real signature unknown
  169. """ Return value-self. """
  170. pass
  171.  
  172. def __rxor__(self, *args, **kwargs): # real signature unknown
  173. """ Return value^self. """
  174. pass
  175.  
  176. def __sizeof__(self): # real signature unknown; restored from __doc__
  177. """ S.__sizeof__() -> size of S in memory, in bytes """
  178. pass
  179.  
  180. def __sub__(self, *args, **kwargs): # real signature unknown
  181. """ Return self-value. """
  182. pass
  183.  
  184. def __xor__(self, *args, **kwargs): # real signature unknown
  185. """ Return self^value. """
  186. pass
  187.  
  188. __hash__ = None

set集合

python常用数据类型内置方法介绍的更多相关文章

  1. 13 python 常用的内置方法介绍

    1.isinstance(obj,cls)和issubclass(sub,super) isinstance(obj,cls)检查是否obj是否是类 cls 的对象 class Foo(object) ...

  2. Python 数据类型常用的内置方法(三)

    目录 Python 数据类型常用的内置方法(三) 1.列表内置方法 1.sort():升序 2.reverse():颠倒顺序 3.列表比较运算 2.字典内置方法 1.对Key的操作 2.len( )- ...

  3. Python 数据类型常用的内置方法(二)

    目录 Python 数据类型常用的内置方法(二) 1.字符串类型常用内置方法 1.upper.lower.isupper.islower 2.startswith.endswith 3.format ...

  4. Python 数据类型常用的内置方法(一)

    目录 Python 数据类型常用的内置方法 1.整型 int 2.浮点型 float 字符串转浮点型: 3.字符串 str 多种类型转字符型: 索引 切片 len( )方法:统计字符串长度/个数 移除 ...

  5. python基础——4(数字、字符串、列表类型的内置方法介绍)

    目录 一.可变与不可变类型 二.数字类型 三.字符串类型 四.列表类型 一.可变与不可变类型 可变类型:值改变,但是id不变,证明就是在改变原值,是可变类型 不可变类型:值改变,id也跟着改变,证明产 ...

  6. python循环与基本数据类型内置方法

    今天又是充满希望的一天呢 一.python循环 1.wuile与else连用 当while没有被关键'break'主动结束的情况下 正常结束循环体代码之后会执行else的子代码 "" ...

  7. python中其他数据类型内置方法

    补充字符串数据类型内置方法 1.移除字符串首尾的指定字符可以选择方向1: s1 = '$$$jason$$$' print(s1.strip('$')) # jason print(s1.lstrip ...

  8. Python学习day07 - Python进阶(1) 内置方法

    figure:last-child { margin-bottom: 0.5rem; } #write ol, #write ul { position: relative; } img { max- ...

  9. python常用的内置函数哈哈

    python常用的内置函数集合做一个归类用的时候可以查找 abs 返回数字x的绝对值或者x的摸 all (iterable)对于可迭代的对象iterable中所有元素x都有bool(x)为true,就 ...

随机推荐

  1. Python3 字符串

    Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32Type & ...

  2. Win7下VS2010使用“ASP.Net 3.5 Claims-aware Template”创建ClaimsAwareWebSite报"HRESULT: 0x80041FEB"错误的解决办法

    问题描述: 使用VS2010的WIF开发模板创建“Claims-aware ASP.NET Site”.“Claims-aware WCF Service”,下载安装后,创建网站时,报错"H ...

  3. 从《BLAME!》说开去——新一代生产级卡通真实感混合的渲染方案

    <BLAME!>是Polygon Pictures Inc.(以下简称PPI)创业33周年以来制作的第一部CG剧场电影,故事来自于贰瓶勉的同名漫画作品(中文译名为<探索者>或者 ...

  4. Swift编程语言SequenceType协议中的一些比较有用的接口

    在Swift编程语言中,大部分容器类(比如Array.Dictionary)都实现了SequenceType协议.SequenceType协议中有不少有趣且简便的方法可用来实现我们不少实际需求.这里将 ...

  5. SIP:用Riverbank的SIP创建C++库的Python模块

    我们发现PyQt做的Python版的PyQt是如此好用,如果想把自己的C++库包装成Python模块该如何实现呢? 这里介绍下用SIP包装C++库时值得参考的功能实现: 需要Python模块中实现C+ ...

  6. 画蛇添足-记spring3 hibernate4整合时遇到问题的处理办法

    最近在来到一个新公司,使用新的spring3,hibernate4框架,在使用注解事务总是不起作用. 首先看配置文件,然后再讲解. 首先是springmvc-servlet.xml,这个配置文件是se ...

  7. 通过PowerShell获取域名whois信息

    Whois 简单来说,就是一个用来查询域名是否已经被注册,以及注册域名的详细信息的数据库(如域名所有人.域名注册商.域名注册日期和过期日期等).通过域名Whois服务器查询,可以查询域名归属者联系方式 ...

  8. Linux Unix 环境变量设置实例

    背景 从第一次写Hello World我们便开始接触环境变量.这最基础的系统设置是必须要掌握的,尤其在是Linux/Unix系统中.比如,哪天某个Java进程出现问题,我们想分析一下其线程堆栈,却发现 ...

  9. 使用 Windows10 自定义交互消息通知

    消息通知是最常用的应用功能之一了,但是由于平台的差异,IOS Android 以及 Windows 都有其特殊性,Android开发者在国内常常都是使用三方的一些推送服务,或者是使用自建的服务器为应用 ...

  10. Oracle数据库入门——如何根据物化视图日志快速刷新物化视图

    Oracle物化视图的快速刷新机制是通过物化视图日志完成的.Oracle如何通过一个物化视图日志就可以支持多个物化视图的快速刷新呢,本文简单的描述一下刷新的原理. 首先,看一下物化视图的结构:SQL& ...