str.isascii() ASCII only
Last updated: 2026-09-22
str.isascii() ASCII only
str.isascii() returns True if every char is ASCII (U+0000-U+007F) or the string is empty.
| Category | String Methods |
|---|---|
| Kind | Built-in Type Method |
| Python Version | 3.7+ |
📝 Syntax
str.isascii()
Returns:bool. True if all chars are ASCII (U+0000-U+007F).
Mutates the original:No (returns a new object)
▶ Example
Edit the code, press Run, and see the result in the output panel:
Output:
True
False
💡 Related Cases
More case studies coming soon — check back later.
❓ FAQ
QWhat does isascii() return for an empty string?
ATrue. This is what distinguishes isascii() from most other is* methods (which require non-empty input).
QWhat is isascii() useful for?
AQuickly determining whether a string is entirely ASCII (U+0000-U+007F), often used to decide whether a more expensive Unicode processing path is needed.
QWhat does it return for Chinese?
AFalse, because Chinese characters are outside the ASCII range.