2024-04-29 13:43:07 发布
网友
当我翻译返回撇号的文本时,我遇到了一个问题 en: "this is me" == fr: "c'est moi",但我得到{}。 为此,我想指定文本的格式,但当我执行脚本时,我得到:
en: "this is me" == fr: "c'est moi"
TypeError: translate() got an unexpected keyword argument 'format'
如果要为format提供参数,则必须使用format_,它接受可选参数:[github code]
format
format_
:type format_: str:param format_: (Optional) One of text or html, to specify if the input text is plain text or HTML.
:type format_: str
:param format_: (Optional) One of text or html, to specify if the input text is plain text or HTML.
text
html
但是,这是针对输入文本而不是输出文本。如果您想转换回一个真正的撇号,您可以使用html.unescape,因为返回的是字符的html表示:[docs]
html.unescape
import html print(html.unescape(text))
如果要为
format
提供参数,则必须使用format_
,它接受可选参数:[github code]但是,这是针对输入文本而不是输出文本。如果您想转换回一个真正的撇号,您可以使用
html.unescape
,因为返回的是字符的html表示:[docs]相关问题 更多 >
编程相关推荐