GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing codescracker.com — Python ascii() function
Python ascii() functionThe ascii() function in Python is used to replace any non-ASCII characters with escape characters. For example: x = "cödëscråckêr.cöm" print(ascii(x)) The characters ö, ë, å, and ê are non-ascii characters. Therefore, the function ascii() converts or replaces all these non-ASCII characters with escape characters. That is:
Here is the output produced by the above Python program, demonstrating the ascii() function: 'c\xf6d\xebscr\xe5ck\xear.c\xf6m' Python ascii() function syntaxThe syntax of the ascii() function in Python is: ascii(obj)
The "obj" is any object, such as a list, string, tuple, dictionary, etc. Python ascii() function exampleHere's a simple Python ascii() function example: x = ["cödes", "crackër", "dot", "com"] x = ascii(x) print(x) Here is its sample output: ['c\xf6des', 'crack\xebr', 'dot', 'com'] Advantages of the ascii() function in Python
Disadvantages of the ascii() function in Python
« Previous Function Next Function » Practice Quizzes
Test your programming and computer science knowledge with interactive MCQs and topic-based quizzes. Popular Topics
Explore the most popular programming and computer science tutorials on CodesCracker. |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |