Python regex for integer?
问题 I'm learning regex and I would like to use a regular expression in Python to define only integers - whole numbers but not decimals. I could make one that only allows numbers by using \d , but it also allows decimal numbers, which I don't want: price = TextField(_('Price'), [ validators.Regexp('\d', message=_('This is not an integer number, please see the example and try again')), validators.Optional()]) How can I change the code to only allow integers? 回答1: Regexp work on the character base,