gpt4 book ai didi

python - url中有unicode字符

转载 作者:行者123 更新时间:2023-11-28 16:48:24 25 4
gpt4 key购买 nike

例如在这个网址中:

(r'^company/لیست-مقالات/$','CompanyHub.views.docList')

لیست مقالات 部分我有 unicode 字符但是我得到这个错误:

Caught UnicodeDecodeError while rendering: 'ascii' codec can't decode byte 0xd9 in position 0: ordinal not in range(128)

最佳答案

需要在字符串前的r前加一个u,或者用unicode方法包起来:

参见 this了解更多信息。

Unicode strings are much like strings, but are specified in the syntax using a preceding 'u' character: u'abc', u"def".

http://docs.python.org/library/stdtypes.html

关于python - url中有unicode字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11384477/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com