Off topic:Rename files that are stored in a list in python
0
0
Entering edit mode
5.1 years ago
Jonas.Koch • 0

Hi!

I generated a list that contains 3 text files

list = [path/A.txt, path/B.txt, path/C.txt]

Now, I want to remove the paths of the filenames, so that I have:

list = [A.txt, B.txt, C.txt]

I tried to use the os.path.basename() function in a for loop:

for file in list: file = os.path.basename(file)

I know this does not work out and I have to adress the indices of the files in the list somehow, but I got stuck...

Can someone help me with this issue?

Greetings!

python lists textfiles path basename • 529 views
ADD COMMENT
This thread is not open. No new answers may be added
Traffic: 2759 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6