这行代码在python中的含义是什么

2024-03-29 15:14:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我知道这是什么:

self.test2 = struct.unpack('I', header.read(4))[0]

但是 我不明白这是什么:

self.lastFileCreated = "f_%06x" % \
                                       self.test2

just : "f_%06x" % \

Tags: selfreadstructheaderjusttest2unpacklastfilecreated
1条回答
网友
1楼 · 发布于 2024-03-29 15:14:01

它只是将最后一个文件名以字符串格式存储为hexa valueof self.test2

这似乎是个数字

更多信息string format

范例

>> "f_%06x"%1
'f_000001'
>>> "f_%06x"%23454323432342
'f_1554e29ddb96'
>>> "f_%06x"%234543
'f_03942f'
>>> "f_%06x"%2345
'f_000929'
>>> "f_%06x"%23
'f_000017'
>>> "f_%06x"%1
'f_000001'
>>> "f_%06x"%2
'f_000002'
>>> "f_%06x"%9
'f_000009'
>>> "f_%06x"%10
'f_00000a'
>>> "f_%06x"%11
'f_00000b'
>>> "f_%06x"%16
'f_000010'
>>> "f_%06x"%15
'f_00000f'

相关问题 更多 >