gpt4 book ai didi

python - Django - 编写希伯来语字符串

转载 作者:太空宇宙 更新时间:2023-11-04 03:39:57 25 4
gpt4 key购买 nike

我正在尝试通过 Django 代码中的解析 rest API 发送希伯来语字符串代码没问题——用英文发送字符串效果很好当字母是希伯来语时,我收到以下错误:

Non-ASCII character '\xd7' but no encoding declared;

如何以编程方式为特定行设置编码?

最佳答案

docs 中有解释:

Python supports writing Unicode literals in any encoding, but you have to declare the encoding being used. This is done by including a special comment as either the first or second line of the source file

在你的情况下:

# -*- coding: utf-8 -*-

关于python - Django - 编写希伯来语字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26982572/

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