python将unicode转为str python将unicode转为str的方法

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

python将unicode转为str python将unicode转为str的方法

  2021-03-24 我要评论
想了解python将unicode转为str的方法的相关内容吗,在本文为您仔细讲解python将unicode转为str的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:python,unicode转str,下面大家一起来学习吧。

问题: 

将u'\u810f\u4e71'转换为'\u810f\u4e71'  

方法: 

s_unicode = u'\u810f\u4e71' 
s_str = s_unicode.encode('unicode-escape').decode('string_escape')  

以上这篇python将unicode转为str的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们