Метод isnumeric ()

Сейчас пишу программу для перевода из одной системы счисления в другую с данных, которые вводит сам пользователь. Хотелось бы сделать проверку того, что вводит пользователь. И я не могу понять какие значения в себя включает метод работы со строками isnumeric (), как я понял от 0-10 и также поддерживает римские, а есть еще какие-нибудь входящие в него знаки или что-то в таком роде?

P.S. Если сказать более объектно интересует именно знак + и -.

P.S.S. И еще хотелось бы узнать в чем разница между этими 3мя методами isdigit(), isnumeric(), isdecimal() ?


Ответы (1 шт):

Автор решения: Victor VosMottor
import re
re.match('[0-9\+\-]', s)

str.isdecimal() Return True if all characters in the string are decimal characters and there is at least one character, False otherwise. Decimal characters are those that can be used to form numbers in base 10, e.g. U+0660, ARABIC-INDIC DIGIT ZERO. Formally a decimal character is a character in the Unicode General Category “Nd”.

str.isdigit() Return True if all characters in the string are digits and there is at least one character, False otherwise. Digits include decimal characters and digits that need special handling, such as the compatibility superscript digits. This covers digits which cannot be used to form numbers in base 10, like the Kharosthi numbers. Formally, a digit is a character that has the property value Numeric_Type=Digit or Numeric_Type=Decimal.

str.isnumeric() Return True if all characters in the string are numeric characters, and there is at least one character, False otherwise. Numeric characters include digit characters, and all characters that have the Unicode numeric value property, e.g. U+2155, VULGAR FRACTION ONE FIFTH. Formally, numeric characters are those with the property value Numeric_Type=Digit, Numeric_Type=Decimal or Numeric_Type=Numeric.

source

→ Ссылка