获得pyc文件的magic数字和创建时间
1 import struct
2 import time
3 import marshal
4 file = open(file_name,'rb')
5 str_magic = file.read(4)
6 str_time = file.read(4)
7 code = marshal.load(file)
8 file.close()
9
10 pyc_magic = struct.unpack('i',str_magic)[0] & (~0xffff0000)
11 pyc_time = time.ctime(struct.unpack('i',str_time)[0])
12 print pyc_magic,pyc_time