current position:Home>How to extract some keywords in the path with Python

How to extract some keywords in the path with Python

2022-05-15 04:46:57CSDN Q & A

img


I saved all the paths in one list , I want to extract all the elements inside, and do the part I frame out label, I don't know what code can be used to realize .




Take the answer :
import osfor item in items:    label = os.path.basename(item).split("_")[0]    print(label)

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.pythonmana.com/2022/131/202205041702589925.html

Random recommended