def _clean_win_chars(string):
 import urllib
 if hasattr(urllib, 'quote'):
  quote = urllib.quote
 else:
  import urllib.parse
  quote = urllib.parse.quote
 for char in ('<', '>', '!', ':', '\\'):
  string = string.replace(char, quote(char))
 return string

def _clean_win_chars ( string ) : import urllib if hasattr ( urllib , 'quote' ) : quote = urllib . quote else : import urllib . parse quote = urllib . parse . quote for char in ( '<' , '>' , '!' , ':' , '\\' ) : string = string . replace ( char , quote ( char ) ) return string
windows cannot encode some characters in filename .