鱼C论坛

 找回密码
 立即注册
查看: 919|回复: 9

[已解决]如何寻找python基础内容的源码

[复制链接]
发表于 2020-4-15 15:46:49 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
最近突然想看一些源码了,想从最基础的看起,比如int类,str类的定义,但是我没能找到这些基础东西的源码在哪求帮助
最佳答案
2020-4-15 15:48:14
本帖最后由 永恒的蓝色梦想 于 2020-4-15 16:03 编辑

这些类的源代码全都是C哦
int源码
str源码
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-4-15 15:48:14 | 显示全部楼层    本楼为最佳答案   
本帖最后由 永恒的蓝色梦想 于 2020-4-15 16:03 编辑

这些类的源代码全都是C哦
int源码
str源码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-4-15 15:49:14 | 显示全部楼层
在idle里面输入help(函数)就OK了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-4-15 15:49:31 | 显示全部楼层
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-4-15 15:49:54 | 显示全部楼层
  1. >>>help(int)
  2. Help on class int in module builtins:

  3. class int(object)
  4. |  int([x]) -> integer
  5. |  int(x, base=10) -> integer
  6. |  
  7. |  Convert a number or string to an integer, or return 0 if no arguments
  8. |  are given.  If x is a number, return x.__int__().  For floating point
  9. |  numbers, this truncates towards zero.
  10. |  
  11. |  If x is not a number or if base is given, then x must be a string,
  12. |  bytes, or bytearray instance representing an integer literal in the
  13. |  given base.  The literal can be preceded by '+' or '-' and be surrounded
  14. |  by whitespace.  The base defaults to 10.  Valid bases are 0 and 2-36.
  15. |  Base 0 means to interpret the base from the string as an integer literal.
  16. |  >>> int('0b100', base=0)
  17. |  4
  18. |  
  19. |  Methods defined here:
  20. |  
  21. |  __abs__(self, /)
  22. |      abs(self)
  23. |  
  24. |  __add__(self, value, /)
  25. |      Return self+value.
  26. |  
  27. |  __and__(self, value, /)
  28. |      Return self&value.
  29. |  
  30. |  __bool__(self, /)
  31. |      self != 0
  32. |  
  33. |  __ceil__(...)
  34. |      Ceiling of an Integral returns itself.
  35. |  
  36. |  __divmod__(self, value, /)
  37. |      Return divmod(self, value).
  38. |  
  39. |  __eq__(self, value, /)
  40. |      Return self==value.
  41. |  
  42. |  __float__(self, /)
  43. |      float(self)
  44. |  
  45. |  __floor__(...)
  46. |      Flooring an Integral returns itself.
  47. |  
  48. |  __floordiv__(self, value, /)
  49. |      Return self//value.
  50. |  
  51. |  __format__(self, format_spec, /)
  52. |      Default object formatter.
  53. |  
  54. |  __ge__(self, value, /)
  55. |      Return self>=value.
  56. |  
  57. |  __getattribute__(self, name, /)
  58. |      Return getattr(self, name).
  59. |  
  60. |  __getnewargs__(self, /)
  61. |  
  62. |  __gt__(self, value, /)
  63. |      Return self>value.
  64. |  
  65. |  __hash__(self, /)
  66. |      Return hash(self).
  67. |  
  68. |  __index__(self, /)
  69. |      Return self converted to an integer, if self is suitable for use as an index into a list.
  70. |  
  71. |  __int__(self, /)
  72. |      int(self)
  73. |  
  74. |  __invert__(self, /)
  75. |      ~self
  76. |  
  77. |  __le__(self, value, /)
  78. |      Return self<=value.
  79. |  
  80. |  __lshift__(self, value, /)
  81. |      Return self<<value.
  82. |  
  83. |  __lt__(self, value, /)
  84. |      Return self<value.
  85. |  
  86. |  __mod__(self, value, /)
  87. |      Return self%value.
  88. |  
  89. |  __mul__(self, value, /)
  90. |      Return self*value.
  91. |  
  92. |  __ne__(self, value, /)
  93. |      Return self!=value.
  94. |  
  95. |  __neg__(self, /)
  96. |      -self
  97. |  
  98. |  __or__(self, value, /)
  99. |      Return self|value.
  100. |  
  101. |  __pos__(self, /)
  102. |      +self
  103. |  
  104. |  __pow__(self, value, mod=None, /)
  105. |      Return pow(self, value, mod).
  106. |  
  107. |  __radd__(self, value, /)
  108. |      Return value+self.
  109. |  
  110. |  __rand__(self, value, /)
  111. |      Return value&self.
  112. |  
  113. |  __rdivmod__(self, value, /)
  114. |      Return divmod(value, self).
  115. |  
  116. |  __repr__(self, /)
  117. |      Return repr(self).
  118. |  
  119. |  __rfloordiv__(self, value, /)
  120. |      Return value//self.
  121. |  
  122. |  __rlshift__(self, value, /)
  123. |      Return value<<self.
  124. |  
  125. |  __rmod__(self, value, /)
  126. |      Return value%self.
  127. |  
  128. |  __rmul__(self, value, /)
  129. |      Return value*self.
  130. |  
  131. |  __ror__(self, value, /)
  132. |      Return value|self.
  133. |  
  134. |  __round__(...)
  135. |      Rounding an Integral returns itself.
  136. |      Rounding with an ndigits argument also returns an integer.
  137. |  
  138. |  __rpow__(self, value, mod=None, /)
  139. |      Return pow(value, self, mod).
  140. |  
  141. |  __rrshift__(self, value, /)
  142. |      Return value>>self.
  143. |  
  144. |  __rshift__(self, value, /)
  145. |      Return self>>value.
  146. |  
  147. |  __rsub__(self, value, /)
  148. |      Return value-self.
  149. |  
  150. |  __rtruediv__(self, value, /)
  151. |      Return value/self.
  152. |  
  153. |  __rxor__(self, value, /)
  154. |      Return value^self.
  155. |  
  156. |  __sizeof__(self, /)
  157. |      Returns size in memory, in bytes.
  158. |  
  159. |  __str__(self, /)
  160. |      Return str(self).
  161. |  
  162. |  __sub__(self, value, /)
  163. |      Return self-value.
  164. |  
  165. |  __truediv__(self, value, /)
  166. |      Return self/value.
  167. |  
  168. |  __trunc__(...)
  169. |      Truncating an Integral returns itself.
  170. |  
  171. |  __xor__(self, value, /)
  172. |      Return self^value.
  173. |  
  174. |  bit_length(self, /)
  175. |      Number of bits necessary to represent self in binary.
  176. |      
  177. |      >>> bin(37)
  178. |      '0b100101'
  179. |      >>> (37).bit_length()
  180. |      6
  181. |  
  182. |  conjugate(...)
  183. |      Returns self, the complex conjugate of any int.
  184. |  
  185. |  to_bytes(self, /, length, byteorder, *, signed=False)
  186. |      Return an array of bytes representing an integer.
  187. |      
  188. |      length
  189. |        Length of bytes object to use.  An OverflowError is raised if the
  190. |        integer is not representable with the given number of bytes.
  191. |      byteorder
  192. |        The byte order used to represent the integer.  If byteorder is 'big',
  193. |        the most significant byte is at the beginning of the byte array.  If
  194. |        byteorder is 'little', the most significant byte is at the end of the
  195. |        byte array.  To request the native byte order of the host system, use
  196. |        `sys.byteorder' as the byte order value.
  197. |      signed
  198. |        Determines whether two's complement is used to represent the integer.
  199. |        If signed is False and a negative integer is given, an OverflowError
  200. |        is raised.
  201. |  
  202. |  ----------------------------------------------------------------------
  203. |  Class methods defined here:
  204. |  
  205. |  from_bytes(bytes, byteorder, *, signed=False) from builtins.type
  206. |      Return the integer represented by the given array of bytes.
  207. |      
  208. |      bytes
  209. |        Holds the array of bytes to convert.  The argument must either
  210. |        support the buffer protocol or be an iterable object producing bytes.
  211. |        Bytes and bytearray are examples of built-in objects that support the
  212. |        buffer protocol.
  213. |      byteorder
  214. |        The byte order used to represent the integer.  If byteorder is 'big',
  215. |        the most significant byte is at the beginning of the byte array.  If
  216. |        byteorder is 'little', the most significant byte is at the end of the
  217. |        byte array.  To request the native byte order of the host system, use
  218. |        `sys.byteorder' as the byte order value.
  219. |      signed
  220. |        Indicates whether two's complement is used to represent the integer.
  221. |  
  222. |  ----------------------------------------------------------------------
  223. |  Static methods defined here:
  224. |  
  225. |  __new__(*args, **kwargs) from builtins.type
  226. |      Create and return a new object.  See help(type) for accurate signature.
  227. |  
  228. |  ----------------------------------------------------------------------
  229. |  Data descriptors defined here:
  230. |  
  231. |  denominator
  232. |      the denominator of a rational number in lowest terms
  233. |  
  234. |  imag
  235. |      the imaginary part of a complex number
  236. |  
  237. |  numerator
  238. |      the numerator of a rational number in lowest terms
  239. |  
  240. |  real
  241. |      the real part of a complex number
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-4-15 15:50:32 | 显示全部楼层
六小鸭 发表于 2020-4-15 15:49
在idle里面输入help(函数)就OK了

帮助信息不是源代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-4-15 15:56:13 | 显示全部楼层
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-4-15 16:01:13 From FishC Mobile | 显示全部楼层
int类型这些都是C语言实现的,并不是用python写的
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-4-15 16:09:28 | 显示全部楼层
感谢大家的帮助,之前还以为int类型的源码也是用python写的,现在打算先看一下能不能弄懂c语言实现的代码,然后在去找点简单的包的源码看一下
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-4-15 16:14:36 | 显示全部楼层
CHNwldcmzy 发表于 2020-4-15 16:09
感谢大家的帮助,之前还以为int类型的源码也是用python写的,现在打算先看一下能不能弄懂c语言实现的代码, ...

如果C不是很好的话,建议不要尝试
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-6-14 15:50

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表