🌐 AI搜索 & 代理 主页
Skip to content

Commit 3596dba

Browse files
adorilsonhugovk
andauthored
gh-106318: Add examples for str.isnumeric() (#142680)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
1 parent e4d3c83 commit 3596dba

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Doc/library/stdtypes.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,6 +2155,21 @@ expression support in the :mod:`re` module).
21552155
that have the Unicode numeric value property, e.g. U+2155,
21562156
VULGAR FRACTION ONE FIFTH. Formally, numeric characters are those with the property
21572157
value Numeric_Type=Digit, Numeric_Type=Decimal or Numeric_Type=Numeric.
2158+
For example:
2159+
2160+
.. doctest::
2161+
2162+
>>> '0123456789'.isnumeric()
2163+
True
2164+
>>> '٠١٢٣٤٥٦٧��٩'.isnumeric() # Arabic-indic digit zero to nine
2165+
True
2166+
>>> ''.isnumeric() # Vulgar fraction one fifth
2167+
True
2168+
>>> '²'.isdecimal(), '²'.isdigit(), '²'.isnumeric()
2169+
(False, True, True)
2170+
2171+
See also :meth:`isdecimal` and :meth:`isdigit`. Numeric characters are
2172+
a superset of decimal numbers.
21582173

21592174

21602175
.. method:: str.isprintable()

0 commit comments

Comments
 (0)