How to replace characters in a string?
Dave
dave at looktowindward.com
Wed Jun 8 04:08:19 EDT 2022
Hi All,
I decided to start a new thread as this really is a new subject.
I've got two that appear to be identical, but fail to compare. After getting the ascii encoding I see that they are indeed different, my question is how can I replace the \u2019m with a regular single quote mark (or apostrophe)?
myCompareFile1 = ascii(myTitleName)
myCompareFile2 = ascii(myCompareFileName)
myCompareFile1: 'I\u2019m Mandy Fly Me'
myCompareFile2: "I'm Mandy Fly Me"
I tried the but it doesn’t seem to work?
myCompareFile1 = ascii(myTitleName)
myCompareFile1.replace("\u2019", "'")
myCompareFile2 = ascii(myCompareFileName)
myCompareFile2.replace("\u2019", "'")
if myCompareFile1 != myCompareFile2:
print('myCompareFile1:',myCompareFile1)
print('myCompareFile2:',myCompareFile2)
myLength1 = len(myCompareFileName)
myLength2 = len(myTitleName)
print('File Name Mismatch - Artist: [' + myArtistName + '] Album: ['+ myAlbumName + '] Track: [' + myTitleName + '] File: [' + myCompareFileName + ']')
if (myLength1 == myLength2):
print('lengths match: ',myLength1)
else:
print('lengths mismatch: ',myLength1,' ',myLength2)
print(' ')
Console:
myCompareFile1: 'I\u2019m Mandy Fly Me'
myCompareFile2: "I'm Mandy Fly Me"
So it looks like the replace isn’t doing anything?
I’m an experienced developer but learning Python.
All the Best
Dave
More information about the Python-list
mailing list