1.re.search(r’\d+(.\d+)?’,s).group()里面的正则表达式匹配整数和小数,(.\d+)?判断有无小数,有则匹配,没有则只匹配整数

2.今天在写一个找出寻找文本(用C语言打印的内容输出到txt)里的变量的最大最小值的小脚本时,遇到传入si,sj两个字符以上的变量不会报错,但传入一个字符的变量就会报错,如下图:
python报错AttributeError: 'NoneType' object has no attribute 'group'和正则匹配整数和小数
python报错AttributeError: 'NoneType' object has no attribute 'group'和正则匹配整数和小数

python报错AttributeError: 'NoneType' object has no attribute 'group'和正则匹配整数和小数
改代码(在判断条件变量后增加‘=’)如下图后不报错:
python报错AttributeError: 'NoneType' object has no attribute 'group'和正则匹配整数和小数
目前还没找到原因,但应该是判断内容匹配的问题。

相关文章:

  • 2021-06-13
  • 2022-01-08
  • 2022-01-29
  • 2021-11-20
  • 2021-07-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
  • 2021-05-24
  • 2022-12-23
  • 2021-07-25
相关资源
相似解决方案