gasolin / zhpy

周蟒, 用中文化 python 語法寫程式
https://pypi.python.org/pypi/zhpy
58 stars 12 forks source link

用 unicode 值来转换中文 #8

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
考虑是用 p_数字_v  来作为转换后的名字,
数字是 unicode 值,
这样无须字典就可以双向转换。

Original issue reported on code.google.com by jhuangjiahua@gmail.com on 22 Aug 2007 at 9:10

Attachments:

GoogleCodeExporter commented 8 years ago
修改一下, 

* 向前相容(map以後要被拿掉) 
* 16進制

{{{
def variable_to_number(tmp):
    """
    convert variable to hex number
    """
    word_list=[]
    for i in tmp:
        ori = str(hex(ord(i)))[2:]
        word_list.append(ori)
    return "_".join(word_list)
}}}

Original comment by gasolin on 23 Aug 2007 at 5:23