判断一个字节数组是否 beginsWith 另外一个字节数组,数组beginswith,import chilk
文章由Byrx.net分享于2019-03-23 07:03:05
判断一个字节数组是否 beginsWith 另外一个字节数组,数组beginswith,import chilk
import chilkatzipData = chilkat.CkByteData()gifData = chilkat.CkByteData()# Zip files begin with these 4 bytes:zipBegin = chilkat.CkByteData()zipBegin.append(\'\\x50\\x4B\\x03\\x04\',4)# GIF files begin with \"GIF89\", which is this byte sequence:gifBegin = chilkat.CkByteData()gifBegin.append(\'\\x47\\x49\\x46\\x38\\x39\',5)success = zipData.loadFile(\"dude.zip\")if (success == True): if (zipData.beginsWith(zipBegin)): print \"Yes, this is a .zip archive!\" else: print \"No, this is not a .zip archive.\"else: print \"Failed to load dude.zip\"success = gifData.loadFile(\"dude.gif\")if (success == True): if (gifData.beginsWith(gifBegin)): print \"Yes, this is a GIF image!\" else: print \"No, this is not a GIF image.\"else: print \"Failed to load dude.gif\"#该片段来自于http://byrx.net
评论关闭