我希望我的 python 程序在文本文件中搜索字符串的特定部分。例如,我的文本文件如下所示:
VERSION_1_0001
VERSION_2_0012
VERSION_3_0391
这些只是例子。我希望我的 python 程序查找“VERSION_2_”,但让它在另一个文本文件中打印出 0012。那可能吗?
到目前为止,我只有这个:
with open('versions.txt', 'r') as verFile:
for line in verFile:
if 'VERSION_2_' in line:
??? (I don't know what would go here so I can get the portion attached to the string I'm finding)
我在这里先向您的帮助表示感谢!