So, I'm sure this is a dumb question, but I'm trying to get a deeper understanding of the python chr () function. Also, I wonder if it is always possible to have an integer argument three digits long or only a fixed length for all ascii values?
chr(20) ## '\x14' chr(020) ## '\x10'
Why does this give me different answers? Does he think β020β is a hex or something else? Also, I am running Python 2.7 on Windows! -Thank!
There is nothing to do with char. It is all about numeric literals. And this is cross-language. 0 indicates oct and 0x indicates hex.
print 010 # 8 print 0x10 # 16
It makes sense to explain chrand ordtogether.
chr
ord
, Python2 (- Python3 0o ), .
0o
Python2 chr - , 256, , ascii. unichr , 0x10FFFF. ord - , ( ) .
256
unichr
0x10FFFF
Python3, chr . bytes([v]). ord .
bytes([v])