Skip to content
KerwinKoo edited this page Dec 26, 2015 · 1 revision

python ASCII处理:

# Get the ASCII number of a character
number = ord(char)

# Get the character given by an ASCII number
char = chr(number)

如果是Unicode字符,可以使用ord()和unichr()函数。

python ctypes 的用法

例:

import ctypes

>>>i = c_int(45)
>>>i.value
45

python 将一个字符串(string)转为字典(dict)

>>> a = "{'a': 'hi', 'b': 'there'}"
>>> b = eval(a)
>>> b
{'a': 'hi', 'b': 'there'}
>>> exec ("c=" + a)
>>> c
{'a': 'hi', 'b': 'there'}
>>>

[[TOC]]

Clone this wiki locally