Jul-11-2017, 06:15 AM
hi. i want to know is there anything like ASCII character definition in python?
Character Definition Like ASCII
|
Jul-11-2017, 06:15 AM
hi. i want to know is there anything like ASCII character definition in python?
Jul-11-2017, 07:01 AM
Hm, what do you mean with character definition?
Try to import the module string and look for the content.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Jul-11-2017, 01:25 PM
If one were to take your question literally, the answer would be no, Python does not define the ASCII character set, rather it adheres to the ASCII character set definition. Basically, it is the numerical representation of printable and certain control characters between decimal 0 and 127 and hearkens back to the days of the teletype. This definition persists even today, whether you are using code pages or Unicode.
Python does provide several ways of working with the ASCII set, for example: >>> chr(120) 'x' >>> ord('x') 120As @DeaD_EyE pointed out, the "string" library also has several options, for example: >>> string.ascii_letters 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' >>> string.printable '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c' >>>
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch" Python 3.6.5, IDE: PyCharm 2018 Community Edition |
|