比如 line = "result of fold 0, instance 3.";

有时候你只要 里面的0, 或者 3 , 怎么办?

只要在正则表达式中加个括号:

pattern = re.compile(r'.?instance.?(\w).')

 

用括号 \w , 那么group(1)就会只有3这个数字;

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-18
  • 2021-12-31
  • 2021-08-16
  • 2021-12-15
猜你喜欢
  • 2022-12-23
  • 2021-08-17
  • 2021-12-10
  • 2021-12-18
  • 2021-05-24
  • 2022-02-12
  • 2022-12-23
相关资源
相似解决方案