python 中的chr()
函數將整數作為參數,並輸出相應的 Unicode 字元
**chr(i)** #where i is an integer in the range 0 to 1,114,111
函數的作用是:只取一個整數作為參數,並返回相應的字元
參數 | 描述 | 必需/可選 |
---|---|---|
整數 | 整數必須在 0 到 1,114,111 的 | |
範圍內 | 需要 |
返回值始終是 Unicode 字元串
| 投入 | 返回值 |
| 整數 | 返回一個 Unicode 字元 |
print(chr(64))
print(chr(65))
print(chr(100))
輸出:
@
A
d
print(chr(-1))
print(chr(1114112))
輸出:
ValueError: chr() arg not in range(0x110000)
ValueError: chr() arg not in range(0x110000)
原創文章,作者:EGL9I,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/126710.html