How can I change only one letter of .mp3 in python? -


so have change letter "ı" because not english character example should change "sanmayın.mp3" "sanmayin.mp3". how can this?

from os import rename, listdir  fnames = listdir('.')   fname in fnames:     print fname     fname.replace('ý','i') 

okay got why didn't work listdir gives of names in english python thinks ı i, how can work in utf-8

use str.replace():

s = 'sanmayın.mp3' s.replace('ı','i') 

result:

sanmayin.mp3 

if needed replace characters within list:

l = ['sanmayın.mp3', 'ın', 'hı'] l = [i.replace('ı','i') in l]  

result:

['sanmayin.mp3', 'in', 'hi'] 

Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -