🌐 AI搜索 & 代理 主页
Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
gh-106318: Some improvements to str.isalnum() example
  • Loading branch information
adorilson committed Aug 8, 2025
commit 7a1058bf9694f3456433a153cfbb06d04b1620c7
9 changes: 5 additions & 4 deletions Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1978,19 +1978,20 @@ expression support in the :mod:`re` module).
Return ``True`` if all characters in the string are alphanumeric and there is at
least one character, ``False`` otherwise. A character ``c`` is alphanumeric if one
of the following returns ``True``: ``c.isalpha()``, ``c.isdecimal()``,
``c.isdigit()``, or ``c.isnumeric()``.
``c.isdigit()``, or ``c.isnumeric()``. For example::

For example::
.. doctest::

>>> ''.isalnum()
False
>>> 'abc123'.isalnum()
True
>>> 'abc123!@#'.isalnum()
False
>>> ''.isalnum()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this is so similar to the last example I think it’s not necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean '' and ' '? I intended to show that an empty string is different from a space character. Frequently, people forget this.

False
>>> ' '.isalnum()
False


.. method:: str.isalpha()

Return ``True`` if all characters in the string are alphabetic and there is at least
Expand Down
Loading