urllib unqoute providing string mismatch between string found using os.walk (Python3)

Dan Sommers 2QdxY4RzWzUUiLuE at potatochowder.com
Sat Dec 21 17:15:47 EST 2019


On 12/21/19 4:46 PM, Ben Hearn wrote:

> import difflib
> print('\n'.join(difflib.ndiff([a], [b])))
> - /Users/macbookpro/Music/tracks_new/_NS_2018/J.Staaf - ¡Móchate! _PromoMix_.wav
> ?                                                                                                      ^^
> + /Users/macbookpro/Music/tracks_new/_NS_2018/J.Staaf - ¡Móchate! _PromoMix_.wav
> ?                                                                                                      ^
> 
> 
> What am I missing when it comes to unquoting the string, or should I do some other fancy operation on the drive string?

I'm going to guess that the trailing characters are newline
(U+0010) and/or carriage return (U+001D) characters.  Use
str.strip() to remove them before comparing:

     a = a.strip()

Dan


More information about the Python-list mailing list