您好,登錄后才能下訂單哦!
內建函數:
divmod,返回商和余數
模塊:
In [17]: from __future__ import division
In [18]: 5/2
Out[18]: 2.5
In [19]: 9/2
Out[19]: 4.5
In [20]: 9.0/2
Out[20]: 4.5
In [21]: 9/2.0
Out[21]: 4.5
得到浮點數的結果
數值類型:
In [1]: 2 ** 31 Out[1]: 2147483648 In [2]: a=99999999999999999999999999999999999999999 In [3]: a Out[3]: 99999999999999999999999999999999999999999L In [4]: type(a) Out[4]: long In [5]: 3/2 Out[5]: 1 In [7]: 3.0/2 Out[7]: 1.5 In [8]: type(3.0/2) Out[8]: float In [9]: a=23j In [10]: type(a) Out[10]: complex In [11]:
字符串:
In [21]: a='abcde' In [22]: a Out[22]: 'abcde' In [23]: a[0] Out[23]: 'a' In [24]: a[4] Out[24]: 'e' In [25]: a[-1] Out[25]: 'e' In [26]: a[0]+[1] In [27]: a[0]+a[1] Out[27]: 'ab' In [28]: a[0:2] Out[28]: 'ab' In [29]: a[:2] Out[29]: 'ab' In [30]: a[1:] Out[30]: 'bcde' In [31]: a[::] Out[31]: 'abcde' In [32]: a[:-1] Out[32]: 'abcd' In [33]: a[::1] Out[33]: 'abcde' In [34]: a[::2] Out[34]: 'ace' In [35]: a[:] Out[35]: 'abcde' In [36]: a[-4:-2] Out[36]: 'bc' In [37]: a[-2:-4:-1] Out[37]: 'dc'
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。