使用Unicode阿拉伯字符串 [英] Unicode arabic string to user it

查看:92
本文介绍了使用Unicode阿拉伯字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个变量,其值类似于 x ='مصطفى',我想将其转换为 u'مصطفى'在某些功能中再次使用它..当我尝试执行 u''+ x 时,它给我一个错误:

i have a variable holding a value like x='مصطفى' and i want to convert it to the form of u'مصطفى' to user it again in some functions .. when i try to do u''+x it alawys give me an error:

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

有什么帮助吗?

推荐答案

感谢我解决了问题:)

thanks I solved it :)

解决方案将是这样做

u''.encode('utf-8')+x

这篇关于使用Unicode阿拉伯字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆