urllib.quote() throws KeyError

前端 未结 3 1249
情话喂你
情话喂你 2020-12-25 10:19

To encode the URI, I used urllib.quote(\"schönefeld\") but when some non-ascii characters exists in string, it thorws

KeyError: u\'\\xe9\'
Code:         


        
3条回答
  •  独厮守ぢ
    2020-12-25 11:08

    I had the exact same error as @underscore but in my case the problem was that map(quoter,s) tried to look for the key u'\xe9' which was not in the _safe_map. However \xe9 was, so I solved the issue by replacing u'\xe9' by \xe9 in s.

    Moreover, shouldn't the return statement be within the try/except ? I also had to change this to completely solve the problem.

提交回复
热议问题