python中chr函数的用法_python中hex,oct,chr,ord函数讲解
hex()
中文說(shuō)明:
轉(zhuǎn)換一個(gè)整數(shù)對(duì)象為十六進(jìn)制的字符串表示
英文說(shuō)明
hex(...)
hex(number) -> string
Return the hexadecimal representation of an integer.
>>> hex(3735928559)
'0xdeadbeef'
代碼演示
oct()
中文說(shuō)明:
返回一個(gè)整數(shù)的八進(jìn)制表示。
英文說(shuō)明
oct(...)
oct(number) -> string
Return the octal representation of an integer.
>>> oct(342391)
'0o1234567'
代碼演示:
chr(i)
中文說(shuō)明:
返回整數(shù)i對(duì)應(yīng)的ASCII字符。與ord()作用相反。
參數(shù)x:取值范圍[0, 255]之間的正數(shù)。
版本:該函數(shù)在python2和python3各個(gè)版本中都可用。不存在兼容性問題。
英文說(shuō)明:
Return a string of one character whose ASCII code is the integer i. For example, chr(97) returns the string 'a'. This is the inverse of ord(). The argument must be in the range [0..255], inclusive; ValueError will be raised if i is outside that range. See also unichr().
代碼演示:
ord(i)
看上chr(i)函數(shù)
代碼演示:
總結(jié)
以上是生活随笔為你收集整理的python中chr函数的用法_python中hex,oct,chr,ord函数讲解的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux如何退出python编辑器_c
- 下一篇: python123 app下载_Pyth