gpt4 book ai didi

python解码字符串问题

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

我从数据库中得到以下字符串:

'23:45 \xe2\x80\x93 23:59'  

输出应该是这样的

'23:45 - 23:59'  

我该如何解码?我试过 utf-8 解码但没有成功

>>> x.decode("utf-8")
u'23:45 \u2013 23:59'

谢谢

最佳答案

这是完全正确的。交互式 python 解释器显示字符串的 repr()。如果您想将其视为正确的字符串,请打印它:

>>> print '23:45 \xe2\x80\x93 23:59'
23:45 – 23:59

关于python解码字符串问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7998399/

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