String Methods
str.isascii()
Check whether all code points fit the ASCII interval U+0000 through U+007F. Empty text passes. Control characters also pass, so this does not establish printability, valid filenames or safety. Use an explicit policy if only visible ASCII is allowed. Takes no arguments.
Formal Syntax & Structure
python syntaxpython
text.isascii()Return Value
bool
True when the stated classification holds; otherwise False.
Working Example
Example Snippetpython
for text in ("ID-42", "سلام", "", "\n"): print(ascii(text), text.isascii())