小编UnL*_*TeD的帖子

在unthon中将unicode cyrillic符号转换为字符串

当我尝试转换unicode时:

a = u"????"
Run Code Online (Sandbox Code Playgroud)

要字符串:

str(a)
Run Code Online (Sandbox Code Playgroud)

我收到了这个错误:

'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)
Run Code Online (Sandbox Code Playgroud)

我需要str(a)给我输出:

>> str(a)
>> '????'
Run Code Online (Sandbox Code Playgroud)

python string unicode python-2.7

5
推荐指数
1
解决办法
2万
查看次数

Python正则表达式匹配{}中的所有单词

我需要在python中使用正则表达式来获取{}中的所有单词

a = 'add {new} sentence {with} this word'
Run Code Online (Sandbox Code Playgroud)

re.findall的结果应该是[new,with]

谢谢

python regex string python-2.7

-3
推荐指数
1
解决办法
4501
查看次数

标签 统计

python ×2

python-2.7 ×2

string ×2

regex ×1

unicode ×1