【发布时间】:2014-11-30 07:47:08
【问题描述】:
假设我有整数 x (-128
我确实喜欢这个。但我做不到。
>>> x = -1
>>> chr(x)
ValueError: chr() arg not in range(256)
【问题讨论】:
-
Python 没有带符号的字符类型...你打算用它做什么?
-
@mgilson 我想将 int 保存为带符号字符的类型。这样我就可以从 C 中读取它。
-
我不确定“从 C 中读取”是什么意思,但您可以这样做:
import ctypes;x=ctypes.c_int32(-1)
标签: python