小编Jav*_*rez的帖子

unicodedata.normalize在python中做什么?

我有以下代码:

import unicodedata
my_var = "this is a string"
my_var2 = " Esta es una oración que está en español "
my_var3 = unicodedata.normalize('NFKD', my_var2).encode('ascii', 'ignore')
output = my_var + my_var3
print(output)
Run Code Online (Sandbox Code Playgroud)

并且python完成时出现以下错误。

**File "C:/path/to/my/file/testing_file.py", line 5, in <module>
    output = my_var + my_var3
TypeError: Can't convert 'bytes' object to str implicitly
Process finished with exit code 1**
Run Code Online (Sandbox Code Playgroud)

我想知道这段代码做什么?这个逻辑正在另一个开发人员的另一个项目上实现,我完全不理解。

我怎么解决这个问题?我需要一个字符串,稍后将对其进行操作。

python ascii typeerror python-2.7

3
推荐指数
2
解决办法
4370
查看次数

标签 统计

ascii ×1

python ×1

python-2.7 ×1

typeerror ×1