Python Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Python Examples

Quick Start
Python Unicode
Python Byte Array
Python Certs
Python Email
Python Encryption
Python FTP
HTML-to-XML
Python HTTP
Python IMAP
Python MHT
Python MIME
Python RSA
Python S/MIME
Python Signatures
Python Socket
Python Spider
Python Tar
Python Upload
Python XML
Python XMP
Python Zip

More Examples...
String
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA

Unreleased...
Bzip2
LZW
Bz2
Icon

 

 

 

 

 

 

 

beginsWith -- Check if Byte Array Begins with Byte Sequence

Determine if a byte array begins with a specific byte sequence.

Download Chilkat Python Library

import chilkat

zipData = 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"

 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2007 Chilkat Software, Inc. All Rights Reserved.