0
我有一個名爲valueType.py
使用在另一個文件中的其他類中定義的定義 - 蟒蛇
文件,它包含以下內容:
class SInt8(ValueType):
# Set _format as big endian signed char(1 byte)
_format = '>b'
class UInt8(ValueType):
# Set _format as big endian unsigned char(1 byte)
_format = '>B'
class SInt16(ValueType):
# Set _format as big endian signed short(2 bytes)
_format = '>h'
class UInt16(ValueType):
# Set _format as big endian unsigned short(2 bytes)
_format = '>H'
class SInt32(ValueType):
# Set _format as big endian signed int(4 bytes)
_format = '>i'
class UInt32(ValueType):
# Set _format as big endian unsigned int(4 bytes)
_format = '>I'
class Real32(ValueType):
# Set _format as big endian float(4 bytes)
_format = '>f'
而且我還有一個文件,我們只是把它parser.py
。在parser.py
中,我定義了一個名爲parameter
的對象,該對象具有一個稱爲parameter.values
的屬性。
parameter.values
包含原始十六進制值,我需要將它們轉換爲十進制格式,我打算使用struct.unpack(fmt, string)
。 我的問題是,我怎樣才能使用_format
在valueType.py
裏面的定義parser.py
?
valueType.py
導入到parser.py
,他們都在同一目錄中