帮助unicode [英] Help for unicode

查看:107
本文介绍了帮助unicode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我是意大利人,我说英语不好。我的问题是:


为什么这个结构:


print u" \ u00" + str(41)


生成一个错误,这个:


print u" \ u0041"不?

我可以在程序中使用所有65536个unicode符号吗?例如,我需要

使用void set的数学符号。它在Windows中的

符号表中有一个0198号码。


谢谢

-

Noixe

Hello,

I''m italian and i not speak a good english. My problem is this:

Why this istruction:

print u"\u00" + str(41)

generate an error and this:

print u"\u0041" no?
Can I use all 65536 symbols of unicode in my program? For example, I need to
use the mathematic symbol of void set. It has a 0198 number in a table of
symbol that there is in Windows.

Thanks
--
Noixe

推荐答案

Noixe写道:
为什么这个结构:

print u\ u00" + str(41)

生成错误,并且:

print u" \ u0041"没有?


因为他们做的事情非常不同。

第一个是先评估你的\ u00并且只有

如果成功(但它没有)添加字符串

" 41"最后。


第二个是评估unicode转义

序列\ u0041这是字符串的一部分。


您不能将这样的字符串组合成

任意unicode转义序列。试试这个吧;


some_variable = 0x0041


打印unichr(some_variable)


我可以在我的程序中使用所有65536个unicode符号?例如,我需要使用void set的数学符号。它在Windows中的
符号表中有一个0198的数字。
Why this istruction:

print u"\u00" + str(41)

generate an error and this:

print u"\u0041" no?
because they are doing very different things.
The first is first evaluating u"\u00" and only
if that succeeds (but it doesn''t) add the string
"41" at the end.

The second is evaluating the unicode escape
sequence \u0041 that is part of the string.

You cannot combine strings like that to form
arbitrary unicode escape sequences. Try this instead;

some_variable=0x0041

print unichr(some_variable)

Can I use all 65536 symbols of unicode in my program? For example, I need to
use the mathematic symbol of void set. It has a 0198 number in a table of
symbol that there is in Windows.




使用所有unicode符号没问题。


但我不认为空集符号是Unicode代码点U + 0198:



No problem to use all unicode symbols.

But I don''t think the empty set symbols is Unicode code point U+0198:

import unicodedata
unicodedata.name(u''\ u0198'')
''LATIN CAPITAL LETTER K with HOOK''unicodedata.lookup(" EMPTY SET")
import unicodedata
unicodedata.name(u''\u0198'') ''LATIN CAPITAL LETTER K WITH HOOK'' unicodedata.lookup("EMPTY SET")



u''\ u2205''


所以我认为你应该使用U + 2205?

--Irmen


u''\u2205''

So I think you should use U+2205 instead?
--Irmen


谢谢!


" Irmen de Jong" < irmen@-NOSPAM-REMOVETHIS-xs4all.nl> ha scritto:


如果我写:


print u''\ u2205''


我有这个错误:UnicodeError:ASCII编码错误:序数不在

范围(128)

为什么?我必须包含一些模块吗?


-

Noixe
"Irmen de Jong" <irmen@-NOSPAM-REMOVETHIS-xs4all.nl> ha scritto:

If I write:

print u''\u2205''

I have this error: UnicodeError: ASCII encoding error: ordinal not in
range(128)
Why? I must include some module?

--
Noixe


这篇关于帮助unicode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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