【发布时间】:2021-07-25 05:31:20
【问题描述】:
我正在尝试从文件名中提取年份。 我有文件,命名为
godzilla_2012.txt
king_arthur_legend_of_the_sword_2016.txt
Teenage_Mutant_ninja_turtle_2017.txt
我想从文件名中提取年份,例如
2012
2016
等等
【问题讨论】:
-
为此使用正则表达式。 docs.python.org/3/library/re.html