2024-06-16 11:50:05 发布
网友
str = "IV_04.03.2019-10-56-45_example_c584536f-ab26-40ce-b5b6-386f755ba747_1.csv"
我想提取example部分和这个c584536f-ab26-40ce-b5b6-386f755ba747
example
c584536f-ab26-40ce-b5b6-386f755ba747
>>> "IV_04.03.2019-10-56-45_example_c584536f-ab26-40ce-b5b6-386f755ba747_1.csv".split("_")[1:-1] ['04.03.2019-10-56-45', 'example', 'c584536f-ab26-40ce-b5b6-386f755ba747']
这将提取被下划线包围且内部不包含下划线的所有子字符串。你知道吗
str = "IV_04.03.2019-10-56-45_example_c584536f-ab26-40ce-b5b6-386f755ba747_1.csv" s1= str.split("_")[2] s2= str.split("_")[3] print (s1) print (s2)
输出:
example c584536f-ab26-40ce-b5b6-386f755ba747
这将提取被下划线包围且内部不包含下划线的所有子字符串。你知道吗
输出:
相关问题 更多 >
编程相关推荐