Linux server1.hosting4iran.com 4.18.0-553.123.2.el8_10.x86_64 #1 SMP Thu May 7 15:28:41 EDT 2026 x86_64
LiteSpeed
Server IP : 185.208.174.156 & Your IP : 216.73.216.67
Domains : 318 Domain
User : satitravel
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
usr /
share /
doc /
python2-docs /
html /
library /
Delete
Unzip
Name
Size
Permission
Date
Action
2to3.html
58.11
KB
-rw-r--r--
2019-03-27 12:19
__builtin__.html
10.81
KB
-rw-r--r--
2019-03-27 12:19
__future__.html
14.34
KB
-rw-r--r--
2019-03-27 12:19
__main__.html
7.34
KB
-rw-r--r--
2019-03-27 12:19
_winreg.html
63.12
KB
-rw-r--r--
2019-03-27 12:19
abc.html
25.22
KB
-rw-r--r--
2019-03-27 12:19
aepack.html
13.83
KB
-rw-r--r--
2019-03-27 12:19
aetools.html
16
KB
-rw-r--r--
2019-03-27 12:19
aetypes.html
20.53
KB
-rw-r--r--
2019-03-27 12:19
aifc.html
24.48
KB
-rw-r--r--
2019-03-27 12:19
al.html
18.23
KB
-rw-r--r--
2019-03-27 12:19
allos.html
34.47
KB
-rw-r--r--
2019-03-27 12:19
anydbm.html
17.7
KB
-rw-r--r--
2019-03-27 12:19
archiving.html
9.84
KB
-rw-r--r--
2019-03-27 12:19
argparse.html
257.44
KB
-rw-r--r--
2019-03-27 12:19
array.html
31.11
KB
-rw-r--r--
2019-03-27 12:19
ast.html
37.27
KB
-rw-r--r--
2019-03-27 12:19
asynchat.html
33.13
KB
-rw-r--r--
2019-03-27 12:19
asyncore.html
39.68
KB
-rw-r--r--
2019-03-27 12:19
atexit.html
18.02
KB
-rw-r--r--
2019-03-27 12:19
audioop.html
33.45
KB
-rw-r--r--
2019-03-27 12:19
autogil.html
8.53
KB
-rw-r--r--
2019-03-27 12:19
base64.html
21.35
KB
-rw-r--r--
2019-03-27 12:19
basehttpserver.html
36.56
KB
-rw-r--r--
2019-03-27 12:19
bastion.html
11.52
KB
-rw-r--r--
2019-03-27 12:19
bdb.html
40.42
KB
-rw-r--r--
2019-03-27 12:19
binascii.html
22.46
KB
-rw-r--r--
2019-03-27 12:19
binhex.html
11.04
KB
-rw-r--r--
2019-03-27 12:19
bisect.html
24.09
KB
-rw-r--r--
2019-03-27 12:19
bsddb.html
27.92
KB
-rw-r--r--
2019-03-27 12:19
bz2.html
28.37
KB
-rw-r--r--
2019-03-27 12:19
calendar.html
40.78
KB
-rw-r--r--
2019-03-27 12:19
carbon.html
50.78
KB
-rw-r--r--
2019-03-27 12:19
cd.html
29.33
KB
-rw-r--r--
2019-03-27 12:19
cgi.html
54.61
KB
-rw-r--r--
2019-03-27 12:19
cgihttpserver.html
13.7
KB
-rw-r--r--
2019-03-27 12:19
cgitb.html
11.98
KB
-rw-r--r--
2019-03-27 12:19
chunk.html
15.53
KB
-rw-r--r--
2019-03-27 12:19
cmath.html
27.7
KB
-rw-r--r--
2019-03-27 12:19
cmd.html
28.36
KB
-rw-r--r--
2019-03-27 12:19
code.html
26.33
KB
-rw-r--r--
2019-03-27 12:19
codecs.html
115.49
KB
-rw-r--r--
2019-03-27 12:19
codeop.html
15.53
KB
-rw-r--r--
2019-03-27 12:19
collections.html
144.19
KB
-rw-r--r--
2019-03-27 12:19
colorpicker.html
7.85
KB
-rw-r--r--
2019-03-27 12:19
colorsys.html
11.64
KB
-rw-r--r--
2019-03-27 12:19
commands.html
15.15
KB
-rw-r--r--
2019-03-27 12:19
compileall.html
18.18
KB
-rw-r--r--
2019-03-27 12:19
compiler.html
74.12
KB
-rw-r--r--
2019-03-27 12:19
configparser.html
66.16
KB
-rw-r--r--
2019-03-27 12:19
constants.html
13.65
KB
-rw-r--r--
2019-03-27 12:19
contextlib.html
22.24
KB
-rw-r--r--
2019-03-27 12:19
cookie.html
40.87
KB
-rw-r--r--
2019-03-27 12:19
cookielib.html
88.9
KB
-rw-r--r--
2019-03-27 12:19
copy.html
12.7
KB
-rw-r--r--
2019-03-27 12:19
copy_reg.html
14.35
KB
-rw-r--r--
2019-03-27 12:19
crypt.html
10.4
KB
-rw-r--r--
2019-03-27 12:19
crypto.html
7.58
KB
-rw-r--r--
2019-03-27 12:19
csv.html
74.66
KB
-rw-r--r--
2019-03-27 12:19
ctypes.html
258.37
KB
-rw-r--r--
2019-03-27 12:19
curses.ascii.html
24.29
KB
-rw-r--r--
2019-03-27 12:19
curses.html
163.58
KB
-rw-r--r--
2019-03-27 12:19
curses.panel.html
15.45
KB
-rw-r--r--
2019-03-27 12:19
custominterp.html
7.84
KB
-rw-r--r--
2019-03-27 12:19
datatypes.html
17.59
KB
-rw-r--r--
2019-03-27 12:19
datetime.html
247.5
KB
-rw-r--r--
2019-03-27 12:19
dbhash.html
16.43
KB
-rw-r--r--
2019-03-27 12:19
dbm.html
13.19
KB
-rw-r--r--
2019-03-27 12:19
debug.html
10.45
KB
-rw-r--r--
2019-03-27 12:19
decimal.html
217.1
KB
-rw-r--r--
2019-03-27 12:19
development.html
14.48
KB
-rw-r--r--
2019-03-27 12:19
difflib.html
89.82
KB
-rw-r--r--
2019-03-27 12:19
dircache.html
12.01
KB
-rw-r--r--
2019-03-27 12:19
dis.html
82.18
KB
-rw-r--r--
2019-03-27 12:19
distribution.html
7.5
KB
-rw-r--r--
2019-03-27 12:19
distutils.html
9.91
KB
-rw-r--r--
2019-03-27 12:19
dl.html
17.25
KB
-rw-r--r--
2019-03-27 12:19
doctest.html
181.53
KB
-rw-r--r--
2019-03-27 12:19
docxmlrpcserver.html
17.16
KB
-rw-r--r--
2019-03-27 12:19
dumbdbm.html
15.18
KB
-rw-r--r--
2019-03-27 12:19
dummy_thread.html
9.83
KB
-rw-r--r--
2019-03-27 12:19
dummy_threading.html
8.72
KB
-rw-r--r--
2019-03-27 12:19
easydialogs.html
32.35
KB
-rw-r--r--
2019-03-27 12:19
email-examples.html
46.31
KB
-rw-r--r--
2019-03-27 12:19
email.charset.html
28.73
KB
-rw-r--r--
2019-03-27 12:19
email.encoders.html
12.55
KB
-rw-r--r--
2019-03-27 12:19
email.errors.html
17.53
KB
-rw-r--r--
2019-03-27 12:19
email.generator.html
22.6
KB
-rw-r--r--
2019-03-27 12:19
email.header.html
28.43
KB
-rw-r--r--
2019-03-27 12:19
email.html
54.42
KB
-rw-r--r--
2019-03-27 12:19
email.iterators.html
12.33
KB
-rw-r--r--
2019-03-27 12:19
email.message.html
68.54
KB
-rw-r--r--
2019-03-27 12:19
email.mime.html
30.91
KB
-rw-r--r--
2019-03-27 12:19
email.parser.html
34.32
KB
-rw-r--r--
2019-03-27 12:19
email.utils.html
26.44
KB
-rw-r--r--
2019-03-27 12:19
ensurepip.html
17.9
KB
-rw-r--r--
2019-03-27 12:19
errno.html
39.3
KB
-rw-r--r--
2019-03-27 12:19
exceptions.html
62.2
KB
-rw-r--r--
2019-03-27 12:19
fcntl.html
25.63
KB
-rw-r--r--
2019-03-27 12:19
filecmp.html
23.43
KB
-rw-r--r--
2019-03-27 12:19
fileformats.html
9.43
KB
-rw-r--r--
2019-03-27 12:19
fileinput.html
26.44
KB
-rw-r--r--
2019-03-27 12:19
filesys.html
10.61
KB
-rw-r--r--
2019-03-27 12:19
fl.html
55.2
KB
-rw-r--r--
2019-03-27 12:19
fm.html
12.7
KB
-rw-r--r--
2019-03-27 12:19
fnmatch.html
15.88
KB
-rw-r--r--
2019-03-27 12:19
formatter.html
36.5
KB
-rw-r--r--
2019-03-27 12:19
fpectl.html
16.48
KB
-rw-r--r--
2019-03-27 12:19
fpformat.html
11.19
KB
-rw-r--r--
2019-03-27 12:19
fractions.html
24.3
KB
-rw-r--r--
2019-03-27 12:19
framework.html
36.07
KB
-rw-r--r--
2019-03-27 12:19
frameworks.html
7.37
KB
-rw-r--r--
2019-03-27 12:19
ftplib.html
48.42
KB
-rw-r--r--
2019-03-27 12:19
functions.html
200.82
KB
-rw-r--r--
2019-03-27 12:19
functools.html
28.95
KB
-rw-r--r--
2019-03-27 12:19
future_builtins.html
14.14
KB
-rw-r--r--
2019-03-27 12:19
gc.html
27.76
KB
-rw-r--r--
2019-03-27 12:19
gdbm.html
17.39
KB
-rw-r--r--
2019-03-27 12:19
gensuitemodule.html
12.28
KB
-rw-r--r--
2019-03-27 12:19
getopt.html
24.69
KB
-rw-r--r--
2019-03-27 12:19
getpass.html
11.16
KB
-rw-r--r--
2019-03-27 12:19
gettext.html
82.98
KB
-rw-r--r--
2019-03-27 12:19
gl.html
23.77
KB
-rw-r--r--
2019-03-27 12:19
glob.html
14.09
KB
-rw-r--r--
2019-03-27 12:19
grp.html
11.05
KB
-rw-r--r--
2019-03-27 12:19
gzip.html
20.09
KB
-rw-r--r--
2019-03-27 12:19
hashlib.html
24.87
KB
-rw-r--r--
2019-03-27 12:19
heapq.html
34.07
KB
-rw-r--r--
2019-03-27 12:19
hmac.html
14.04
KB
-rw-r--r--
2019-03-27 12:19
hotshot.html
19.67
KB
-rw-r--r--
2019-03-27 12:19
htmllib.html
27.03
KB
-rw-r--r--
2019-03-27 12:19
htmlparser.html
41.44
KB
-rw-r--r--
2019-03-27 12:19
httplib.html
69.27
KB
-rw-r--r--
2019-03-27 12:19
i18n.html
9.81
KB
-rw-r--r--
2019-03-27 12:19
ic.html
18.22
KB
-rw-r--r--
2019-03-27 12:19
idle.html
41.16
KB
-rw-r--r--
2019-03-27 12:19
imageop.html
15.72
KB
-rw-r--r--
2019-03-27 12:19
imaplib.html
57.14
KB
-rw-r--r--
2019-03-27 12:19
imgfile.html
12.43
KB
-rw-r--r--
2019-03-27 12:19
imghdr.html
11.95
KB
-rw-r--r--
2019-03-27 12:19
imp.html
36.72
KB
-rw-r--r--
2019-03-27 12:19
importlib.html
8.72
KB
-rw-r--r--
2019-03-27 12:19
imputil.html
32.78
KB
-rw-r--r--
2019-03-27 12:19
index.html
77.23
KB
-rw-r--r--
2019-03-27 12:19
inspect.html
55.49
KB
-rw-r--r--
2019-03-27 12:19
internet.html
25.53
KB
-rw-r--r--
2019-03-27 12:19
intro.html
9.13
KB
-rw-r--r--
2019-03-27 12:19
io.html
111.04
KB
-rw-r--r--
2019-03-27 12:19
ipc.html
16.21
KB
-rw-r--r--
2019-03-27 12:19
itertools.html
122.46
KB
-rw-r--r--
2019-03-27 12:19
jpeg.html
13.43
KB
-rw-r--r--
2019-03-27 12:19
json.html
71.95
KB
-rw-r--r--
2019-03-27 12:19
keyword.html
8.02
KB
-rw-r--r--
2019-03-27 12:19
language.html
11.41
KB
-rw-r--r--
2019-03-27 12:19
linecache.html
11.15
KB
-rw-r--r--
2019-03-27 12:19
locale.html
60.13
KB
-rw-r--r--
2019-03-27 12:19
logging.config.html
78.17
KB
-rw-r--r--
2019-03-27 12:19
logging.handlers.html
78.31
KB
-rw-r--r--
2019-03-27 12:19
logging.html
107.67
KB
-rw-r--r--
2019-03-27 12:19
mac.html
22.83
KB
-rw-r--r--
2019-03-27 12:19
macos.html
15.75
KB
-rw-r--r--
2019-03-27 12:19
macosa.html
13.75
KB
-rw-r--r--
2019-03-27 12:19
macostools.html
16.5
KB
-rw-r--r--
2019-03-27 12:19
macpath.html
8.19
KB
-rw-r--r--
2019-03-27 12:19
mailbox.html
167.11
KB
-rw-r--r--
2019-03-27 12:19
mailcap.html
13.8
KB
-rw-r--r--
2019-03-27 12:19
markup.html
19.4
KB
-rw-r--r--
2019-03-27 12:19
marshal.html
19
KB
-rw-r--r--
2019-03-27 12:19
math.html
42.98
KB
-rw-r--r--
2019-03-27 12:19
md5.html
14.77
KB
-rw-r--r--
2019-03-27 12:19
mhlib.html
23.56
KB
-rw-r--r--
2019-03-27 12:19
mimetools.html
20.71
KB
-rw-r--r--
2019-03-27 12:19
mimetypes.html
29.92
KB
-rw-r--r--
2019-03-27 12:19
mimewriter.html
15.7
KB
-rw-r--r--
2019-03-27 12:19
mimify.html
14.92
KB
-rw-r--r--
2019-03-27 12:19
miniaeframe.html
12.8
KB
-rw-r--r--
2019-03-27 12:19
misc.html
7.07
KB
-rw-r--r--
2019-03-27 12:19
mm.html
9.35
KB
-rw-r--r--
2019-03-27 12:19
mmap.html
30.11
KB
-rw-r--r--
2019-03-27 12:19
modulefinder.html
17.67
KB
-rw-r--r--
2019-03-27 12:19
modules.html
8.81
KB
-rw-r--r--
2019-03-27 12:19
msilib.html
56.5
KB
-rw-r--r--
2019-03-27 12:19
msvcrt.html
20.73
KB
-rw-r--r--
2019-03-27 12:19
multifile.html
25.64
KB
-rw-r--r--
2019-03-27 12:19
multiprocessing.html
404.82
KB
-rw-r--r--
2019-03-27 12:19
mutex.html
11.86
KB
-rw-r--r--
2019-03-27 12:19
netdata.html
17.95
KB
-rw-r--r--
2019-03-27 12:19
netrc.html
13.69
KB
-rw-r--r--
2019-03-27 12:19
new.html
12.87
KB
-rw-r--r--
2019-03-27 12:19
nis.html
11.23
KB
-rw-r--r--
2019-03-27 12:19
nntplib.html
44.62
KB
-rw-r--r--
2019-03-27 12:19
numbers.html
39.68
KB
-rw-r--r--
2019-03-27 12:19
numeric.html
13.96
KB
-rw-r--r--
2019-03-27 12:19
operator.html
91.43
KB
-rw-r--r--
2019-03-27 12:19
optparse.html
244.25
KB
-rw-r--r--
2019-03-27 12:19
os.html
234.57
KB
-rw-r--r--
2019-03-27 12:19
os.path.html
42.38
KB
-rw-r--r--
2019-03-27 12:19
ossaudiodev.html
44.53
KB
-rw-r--r--
2019-03-27 12:19
othergui.html
9.18
KB
-rw-r--r--
2019-03-27 12:19
parser.html
41.56
KB
-rw-r--r--
2019-03-27 12:19
pdb.html
37.7
KB
-rw-r--r--
2019-03-27 12:19
persistence.html
15.31
KB
-rw-r--r--
2019-03-27 12:19
pickle.html
107.11
KB
-rw-r--r--
2019-03-27 12:19
pickletools.html
11.21
KB
-rw-r--r--
2019-03-27 12:19
pipes.html
19.22
KB
-rw-r--r--
2019-03-27 12:19
pkgutil.html
26.73
KB
-rw-r--r--
2019-03-27 12:19
platform.html
30.86
KB
-rw-r--r--
2019-03-27 12:19
plistlib.html
17.91
KB
-rw-r--r--
2019-03-27 12:19
popen2.html
26.95
KB
-rw-r--r--
2019-03-27 12:19
poplib.html
23.75
KB
-rw-r--r--
2019-03-27 12:19
posix.html
16.24
KB
-rw-r--r--
2019-03-27 12:19
posixfile.html
20.89
KB
-rw-r--r--
2019-03-27 12:19
pprint.html
31.45
KB
-rw-r--r--
2019-03-27 12:19
profile.html
71.08
KB
-rw-r--r--
2019-03-27 12:19
pty.html
9.96
KB
-rw-r--r--
2019-03-27 12:19
pwd.html
12.1
KB
-rw-r--r--
2019-03-27 12:19
py_compile.html
11.65
KB
-rw-r--r--
2019-03-27 12:19
pyclbr.html
15.44
KB
-rw-r--r--
2019-03-27 12:19
pydoc.html
13.33
KB
-rw-r--r--
2019-03-27 12:19
pyexpat.html
78.99
KB
-rw-r--r--
2019-03-27 12:19
python.html
12.55
KB
-rw-r--r--
2019-03-27 12:19
queue.html
26.23
KB
-rw-r--r--
2019-03-27 12:19
quopri.html
12.44
KB
-rw-r--r--
2019-03-27 12:19
random.html
41.72
KB
-rw-r--r--
2019-03-27 12:19
re.html
152.33
KB
-rw-r--r--
2019-03-27 12:19
readline.html
36.51
KB
-rw-r--r--
2019-03-27 12:19
repr.html
21.27
KB
-rw-r--r--
2019-03-27 12:19
resource.html
27.62
KB
-rw-r--r--
2019-03-27 12:19
restricted.html
12.08
KB
-rw-r--r--
2019-03-27 12:19
rexec.html
39.62
KB
-rw-r--r--
2019-03-27 12:19
rfc822.html
45.32
KB
-rw-r--r--
2019-03-27 12:19
rlcompleter.html
14.12
KB
-rw-r--r--
2019-03-27 12:19
robotparser.html
13.09
KB
-rw-r--r--
2019-03-27 12:19
runpy.html
21.41
KB
-rw-r--r--
2019-03-27 12:19
sched.html
19.41
KB
-rw-r--r--
2019-03-27 12:19
scrolledtext.html
9.5
KB
-rw-r--r--
2019-03-27 12:19
select.html
43.06
KB
-rw-r--r--
2019-03-27 12:19
sets.html
39.21
KB
-rw-r--r--
2019-03-27 12:19
sgi.html
10.13
KB
-rw-r--r--
2019-03-27 12:19
sgmllib.html
33.66
KB
-rw-r--r--
2019-03-27 12:19
sha.html
12.76
KB
-rw-r--r--
2019-03-27 12:19
shelve.html
29.25
KB
-rw-r--r--
2019-03-27 12:19
shlex.html
34.21
KB
-rw-r--r--
2019-03-27 12:19
shutil.html
44.39
KB
-rw-r--r--
2019-03-27 12:19
signal.html
33.23
KB
-rw-r--r--
2019-03-27 12:19
simplehttpserver.html
19.87
KB
-rw-r--r--
2019-03-27 12:19
simplexmlrpcserver.html
36.91
KB
-rw-r--r--
2019-03-27 12:19
site.html
26.26
KB
-rw-r--r--
2019-03-27 12:19
smtpd.html
13.27
KB
-rw-r--r--
2019-03-27 12:19
smtplib.html
45.95
KB
-rw-r--r--
2019-03-27 12:19
sndhdr.html
10.74
KB
-rw-r--r--
2019-03-27 12:19
socket.html
113.69
KB
-rw-r--r--
2019-03-27 12:19
socketserver.html
74.64
KB
-rw-r--r--
2019-03-27 12:19
someos.html
16.09
KB
-rw-r--r--
2019-03-27 12:19
spwd.html
10.9
KB
-rw-r--r--
2019-03-27 12:19
sqlite3.html
146.5
KB
-rw-r--r--
2019-03-27 12:19
ssl.html
197.71
KB
-rw-r--r--
2019-03-27 12:19
stat.html
33.79
KB
-rw-r--r--
2019-03-27 12:19
statvfs.html
11.06
KB
-rw-r--r--
2019-03-27 12:19
stdtypes.html
291.16
KB
-rw-r--r--
2019-03-27 12:19
string.html
117.4
KB
-rw-r--r--
2019-03-27 12:19
stringio.html
19.59
KB
-rw-r--r--
2019-03-27 12:19
stringprep.html
17.31
KB
-rw-r--r--
2019-03-27 12:19
strings.html
15.53
KB
-rw-r--r--
2019-03-27 12:19
struct.html
43.84
KB
-rw-r--r--
2019-03-27 12:19
subprocess.html
107.86
KB
-rw-r--r--
2019-03-27 12:19
sun.html
7.08
KB
-rw-r--r--
2019-03-27 12:19
sunau.html
29.31
KB
-rw-r--r--
2019-03-27 12:19
sunaudio.html
18.79
KB
-rw-r--r--
2019-03-27 12:19
symbol.html
7.95
KB
-rw-r--r--
2019-03-27 12:19
symtable.html
25.26
KB
-rw-r--r--
2019-03-27 12:19
sys.html
108.39
KB
-rw-r--r--
2019-03-27 12:19
sysconfig.html
25.68
KB
-rw-r--r--
2019-03-27 12:19
syslog.html
19.27
KB
-rw-r--r--
2019-03-27 12:19
tabnanny.html
11.13
KB
-rw-r--r--
2019-03-27 12:19
tarfile.html
86.65
KB
-rw-r--r--
2019-03-27 12:19
telnetlib.html
27.13
KB
-rw-r--r--
2019-03-27 12:19
tempfile.html
31.16
KB
-rw-r--r--
2019-03-27 12:19
termios.html
16.9
KB
-rw-r--r--
2019-03-27 12:19
test.html
55.69
KB
-rw-r--r--
2019-03-27 12:19
textwrap.html
29.43
KB
-rw-r--r--
2019-03-27 12:19
thread.html
20.98
KB
-rw-r--r--
2019-03-27 12:19
threading.html
84.62
KB
-rw-r--r--
2019-03-27 12:19
time.html
62.3
KB
-rw-r--r--
2019-03-27 12:19
timeit.html
39.58
KB
-rw-r--r--
2019-03-27 12:19
tix.html
49.4
KB
-rw-r--r--
2019-03-27 12:19
tk.html
25.95
KB
-rw-r--r--
2019-03-27 12:19
tkinter.html
82.34
KB
-rw-r--r--
2019-03-27 12:19
token.html
20.51
KB
-rw-r--r--
2019-03-27 12:19
tokenize.html
20.12
KB
-rw-r--r--
2019-03-27 12:19
trace.html
28
KB
-rw-r--r--
2019-03-27 12:19
traceback.html
39.94
KB
-rw-r--r--
2019-03-27 12:19
ttk.html
105.97
KB
-rw-r--r--
2019-03-27 12:19
tty.html
9.52
KB
-rw-r--r--
2019-03-27 12:19
turtle.html
225.08
KB
-rw-r--r--
2019-03-27 12:19
types.html
29.13
KB
-rw-r--r--
2019-03-27 12:19
undoc.html
24.1
KB
-rw-r--r--
2019-03-27 12:19
unicodedata.html
19.71
KB
-rw-r--r--
2019-03-27 12:19
unittest.html
219.75
KB
-rw-r--r--
2019-03-27 12:19
unix.html
10.96
KB
-rw-r--r--
2019-03-27 12:19
urllib.html
66.67
KB
-rw-r--r--
2019-03-27 12:19
urllib2.html
110.72
KB
-rw-r--r--
2019-03-27 12:19
urlparse.html
42.46
KB
-rw-r--r--
2019-03-27 12:19
user.html
12.41
KB
-rw-r--r--
2019-03-27 12:19
userdict.html
31.32
KB
-rw-r--r--
2019-03-27 12:19
uu.html
11.53
KB
-rw-r--r--
2019-03-27 12:19
uuid.html
29.43
KB
-rw-r--r--
2019-03-27 12:19
warnings.html
49.76
KB
-rw-r--r--
2019-03-27 12:19
wave.html
24.31
KB
-rw-r--r--
2019-03-27 12:19
weakref.html
37.9
KB
-rw-r--r--
2019-03-27 12:19
webbrowser.html
25.94
KB
-rw-r--r--
2019-03-27 12:19
whichdb.html
9.28
KB
-rw-r--r--
2019-03-27 12:19
windows.html
9.59
KB
-rw-r--r--
2019-03-27 12:19
winsound.html
19.99
KB
-rw-r--r--
2019-03-27 12:19
wsgiref.html
86.31
KB
-rw-r--r--
2019-03-27 12:19
xdrlib.html
32.24
KB
-rw-r--r--
2019-03-27 12:19
xml.dom.html
95.58
KB
-rw-r--r--
2019-03-27 12:19
xml.dom.minidom.html
42.22
KB
-rw-r--r--
2019-03-27 12:19
xml.dom.pulldom.html
13.51
KB
-rw-r--r--
2019-03-27 12:19
xml.etree.elementtree.html
109.18
KB
-rw-r--r--
2019-03-27 12:19
xml.html
17.58
KB
-rw-r--r--
2019-03-27 12:19
xml.sax.handler.html
40.9
KB
-rw-r--r--
2019-03-27 12:19
xml.sax.html
22.91
KB
-rw-r--r--
2019-03-27 12:19
xml.sax.reader.html
43.75
KB
-rw-r--r--
2019-03-27 12:19
xml.sax.utils.html
15.71
KB
-rw-r--r--
2019-03-27 12:19
xmlrpclib.html
67.57
KB
-rw-r--r--
2019-03-27 12:19
zipfile.html
60.77
KB
-rw-r--r--
2019-03-27 12:19
zipimport.html
22.24
KB
-rw-r--r--
2019-03-27 12:19
zlib.html
30.5
KB
-rw-r--r--
2019-03-27 12:19
Save
Rename
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="X-UA-Compatible" content="IE=Edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>7.3. struct — Interpret strings as packed binary data — Python 2.7.16 documentation</title> <link rel="stylesheet" href="../_static/classic.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="../_static/sidebar.js"></script> <link rel="search" type="application/opensearchdescription+xml" title="Search within Python 2.7.16 documentation" href="../_static/opensearch.xml"/> <link rel="author" title="About these documents" href="../about.html" /> <link rel="index" title="Index" href="../genindex.html" /> <link rel="search" title="Search" href="../search.html" /> <link rel="copyright" title="Copyright" href="../copyright.html" /> <link rel="next" title="7.4. difflib — Helpers for computing deltas" href="difflib.html" /> <link rel="prev" title="7.2. re — Regular expression operations" href="re.html" /> <link rel="shortcut icon" type="image/png" href="../_static/py.png" /> <link rel="canonical" href="https://docs.python.org/2/library/struct.html" /> <script type="text/javascript" src="../_static/copybutton.js"></script> </head><body> <div class="related" role="navigation" aria-label="related navigation"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="difflib.html" title="7.4. difflib — Helpers for computing deltas" accesskey="N">next</a> |</li> <li class="right" > <a href="re.html" title="7.2. re — Regular expression operations" accesskey="P">previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="https://www.python.org/">Python</a> »</li> <li> <a href="../index.html">Python 2.7.16 documentation</a> » </li> <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li> <li class="nav-item nav-item-2"><a href="strings.html" accesskey="U">7. String Services</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <div class="section" id="module-struct"> <span id="struct-interpret-strings-as-packed-binary-data"></span><h1>7.3. <a class="reference internal" href="#module-struct" title="struct: Interpret strings as packed binary data."><code class="xref py py-mod docutils literal notranslate"><span class="pre">struct</span></code></a> — Interpret strings as packed binary data<a class="headerlink" href="#module-struct" title="Permalink to this headline">¶</a></h1> <p id="index-0">This module performs conversions between Python values and C structs represented as Python strings. This can be used in handling binary data stored in files or from network connections, among other sources. It uses <a class="reference internal" href="#struct-format-strings"><span class="std std-ref">Format Strings</span></a> as compact descriptions of the layout of the C structs and the intended conversion to/from Python values.</p> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">By default, the result of packing a given C struct includes pad bytes in order to maintain proper alignment for the C types involved; similarly, alignment is taken into account when unpacking. This behavior is chosen so that the bytes of a packed struct correspond exactly to the layout in memory of the corresponding C struct. To handle platform-independent data formats or omit implicit pad bytes, use <code class="docutils literal notranslate"><span class="pre">standard</span></code> size and alignment instead of <code class="docutils literal notranslate"><span class="pre">native</span></code> size and alignment: see <a class="reference internal" href="#struct-alignment"><span class="std std-ref">Byte Order, Size, and Alignment</span></a> for details.</p> </div> <div class="section" id="functions-and-exceptions"> <h2>7.3.1. Functions and Exceptions<a class="headerlink" href="#functions-and-exceptions" title="Permalink to this headline">¶</a></h2> <p>The module defines the following exception and functions:</p> <dl class="exception"> <dt id="struct.error"> <em class="property">exception </em><code class="descclassname">struct.</code><code class="descname">error</code><a class="headerlink" href="#struct.error" title="Permalink to this definition">¶</a></dt> <dd><p>Exception raised on various occasions; argument is a string describing what is wrong.</p> </dd></dl> <dl class="function"> <dt id="struct.pack"> <code class="descclassname">struct.</code><code class="descname">pack</code><span class="sig-paren">(</span><em>fmt</em>, <em>v1</em>, <em>v2</em>, <em>...</em><span class="sig-paren">)</span><a class="headerlink" href="#struct.pack" title="Permalink to this definition">¶</a></dt> <dd><p>Return a string containing the values <code class="docutils literal notranslate"><span class="pre">v1,</span> <span class="pre">v2,</span> <span class="pre">...</span></code> packed according to the given format. The arguments must match the values required by the format exactly.</p> </dd></dl> <dl class="function"> <dt id="struct.pack_into"> <code class="descclassname">struct.</code><code class="descname">pack_into</code><span class="sig-paren">(</span><em>fmt</em>, <em>buffer</em>, <em>offset</em>, <em>v1</em>, <em>v2</em>, <em>...</em><span class="sig-paren">)</span><a class="headerlink" href="#struct.pack_into" title="Permalink to this definition">¶</a></dt> <dd><p>Pack the values <code class="docutils literal notranslate"><span class="pre">v1,</span> <span class="pre">v2,</span> <span class="pre">...</span></code> according to the given format, write the packed bytes into the writable <em>buffer</em> starting at <em>offset</em>. Note that the offset is a required argument.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.5.</span></p> </div> </dd></dl> <dl class="function"> <dt id="struct.unpack"> <code class="descclassname">struct.</code><code class="descname">unpack</code><span class="sig-paren">(</span><em>fmt</em>, <em>string</em><span class="sig-paren">)</span><a class="headerlink" href="#struct.unpack" title="Permalink to this definition">¶</a></dt> <dd><p>Unpack the string (presumably packed by <code class="docutils literal notranslate"><span class="pre">pack(fmt,</span> <span class="pre">...)</span></code>) according to the given format. The result is a tuple even if it contains exactly one item. The string must contain exactly the amount of data required by the format (<code class="docutils literal notranslate"><span class="pre">len(string)</span></code> must equal <code class="docutils literal notranslate"><span class="pre">calcsize(fmt)</span></code>).</p> </dd></dl> <dl class="function"> <dt id="struct.unpack_from"> <code class="descclassname">struct.</code><code class="descname">unpack_from</code><span class="sig-paren">(</span><em>fmt</em>, <em>buffer</em><span class="optional">[</span>, <em>offset=0</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#struct.unpack_from" title="Permalink to this definition">¶</a></dt> <dd><p>Unpack the <em>buffer</em> according to the given format. The result is a tuple even if it contains exactly one item. The <em>buffer</em> must contain at least the amount of data required by the format (<code class="docutils literal notranslate"><span class="pre">len(buffer[offset:])</span></code> must be at least <code class="docutils literal notranslate"><span class="pre">calcsize(fmt)</span></code>).</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.5.</span></p> </div> </dd></dl> <dl class="function"> <dt id="struct.calcsize"> <code class="descclassname">struct.</code><code class="descname">calcsize</code><span class="sig-paren">(</span><em>fmt</em><span class="sig-paren">)</span><a class="headerlink" href="#struct.calcsize" title="Permalink to this definition">¶</a></dt> <dd><p>Return the size of the struct (and hence of the string) corresponding to the given format.</p> </dd></dl> </div> <div class="section" id="format-strings"> <span id="struct-format-strings"></span><h2>7.3.2. Format Strings<a class="headerlink" href="#format-strings" title="Permalink to this headline">¶</a></h2> <p>Format strings are the mechanism used to specify the expected layout when packing and unpacking data. They are built up from <a class="reference internal" href="#format-characters"><span class="std std-ref">Format Characters</span></a>, which specify the type of data being packed/unpacked. In addition, there are special characters for controlling the <a class="reference internal" href="#struct-alignment"><span class="std std-ref">Byte Order, Size, and Alignment</span></a>.</p> <div class="section" id="byte-order-size-and-alignment"> <span id="struct-alignment"></span><h3>7.3.2.1. Byte Order, Size, and Alignment<a class="headerlink" href="#byte-order-size-and-alignment" title="Permalink to this headline">¶</a></h3> <p>By default, C types are represented in the machine’s native format and byte order, and properly aligned by skipping pad bytes if necessary (according to the rules used by the C compiler).</p> <p>Alternatively, the first character of the format string can be used to indicate the byte order, size and alignment of the packed data, according to the following table:</p> <table border="1" class="docutils"> <colgroup> <col width="20%" /> <col width="43%" /> <col width="18%" /> <col width="20%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">Character</th> <th class="head">Byte order</th> <th class="head">Size</th> <th class="head">Alignment</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">@</span></code></td> <td>native</td> <td>native</td> <td>native</td> </tr> <tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">=</span></code></td> <td>native</td> <td>standard</td> <td>none</td> </tr> <tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre"><</span></code></td> <td>little-endian</td> <td>standard</td> <td>none</td> </tr> <tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">></span></code></td> <td>big-endian</td> <td>standard</td> <td>none</td> </tr> <tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">!</span></code></td> <td>network (= big-endian)</td> <td>standard</td> <td>none</td> </tr> </tbody> </table> <p>If the first character is not one of these, <code class="docutils literal notranslate"><span class="pre">'@'</span></code> is assumed.</p> <p>Native byte order is big-endian or little-endian, depending on the host system. For example, Intel x86 and AMD64 (x86-64) are little-endian; Motorola 68000 and PowerPC G5 are big-endian; ARM and Intel Itanium feature switchable endianness (bi-endian). Use <code class="docutils literal notranslate"><span class="pre">sys.byteorder</span></code> to check the endianness of your system.</p> <p>Native size and alignment are determined using the C compiler’s <code class="docutils literal notranslate"><span class="pre">sizeof</span></code> expression. This is always combined with native byte order.</p> <p>Standard size depends only on the format character; see the table in the <a class="reference internal" href="#format-characters"><span class="std std-ref">Format Characters</span></a> section.</p> <p>Note the difference between <code class="docutils literal notranslate"><span class="pre">'@'</span></code> and <code class="docutils literal notranslate"><span class="pre">'='</span></code>: both use native byte order, but the size and alignment of the latter is standardized.</p> <p>The form <code class="docutils literal notranslate"><span class="pre">'!'</span></code> is available for those poor souls who claim they can’t remember whether network byte order is big-endian or little-endian.</p> <p>There is no way to indicate non-native byte order (force byte-swapping); use the appropriate choice of <code class="docutils literal notranslate"><span class="pre">'<'</span></code> or <code class="docutils literal notranslate"><span class="pre">'>'</span></code>.</p> <p>Notes:</p> <ol class="arabic simple"> <li>Padding is only automatically added between successive structure members. No padding is added at the beginning or the end of the encoded struct.</li> <li>No padding is added when using non-native size and alignment, e.g. with ‘<’, ‘>’, ‘=’, and ‘!’.</li> <li>To align the end of a structure to the alignment requirement of a particular type, end the format with the code for that type with a repeat count of zero. See <a class="reference internal" href="#struct-examples"><span class="std std-ref">Examples</span></a>.</li> </ol> </div> <div class="section" id="format-characters"> <span id="id1"></span><h3>7.3.2.2. Format Characters<a class="headerlink" href="#format-characters" title="Permalink to this headline">¶</a></h3> <p>Format characters have the following meaning; the conversion between C and Python values should be obvious given their types. The ‘Standard size’ column refers to the size of the packed value in bytes when using standard size; that is, when the format string starts with one of <code class="docutils literal notranslate"><span class="pre">'<'</span></code>, <code class="docutils literal notranslate"><span class="pre">'>'</span></code>, <code class="docutils literal notranslate"><span class="pre">'!'</span></code> or <code class="docutils literal notranslate"><span class="pre">'='</span></code>. When using native size, the size of the packed value is platform-dependent.</p> <table border="1" class="docutils"> <colgroup> <col width="10%" /> <col width="32%" /> <col width="24%" /> <col width="20%" /> <col width="15%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">Format</th> <th class="head">C Type</th> <th class="head">Python type</th> <th class="head">Standard size</th> <th class="head">Notes</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">x</span></code></td> <td>pad byte</td> <td>no value</td> <td> </td> <td> </td> </tr> <tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">c</span></code></td> <td><code class="xref c c-type docutils literal notranslate"><span class="pre">char</span></code></td> <td>string of length 1</td> <td>1</td> <td> </td> </tr> <tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">b</span></code></td> <td><code class="xref c c-type docutils literal notranslate"><span class="pre">signed</span> <span class="pre">char</span></code></td> <td>integer</td> <td>1</td> <td>(3)</td> </tr> <tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">B</span></code></td> <td><code class="xref c c-type docutils literal notranslate"><span class="pre">unsigned</span> <span class="pre">char</span></code></td> <td>integer</td> <td>1</td> <td>(3)</td> </tr> <tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">?</span></code></td> <td><code class="xref c c-type docutils literal notranslate"><span class="pre">_Bool</span></code></td> <td>bool</td> <td>1</td> <td>(1)</td> </tr> <tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">h</span></code></td> <td><code class="xref c c-type docutils literal notranslate"><span class="pre">short</span></code></td> <td>integer</td> <td>2</td> <td>(3)</td> </tr> <tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">H</span></code></td> <td><code class="xref c c-type docutils literal notranslate"><span class="pre">unsigned</span> <span class="pre">short</span></code></td> <td>integer</td> <td>2</td> <td>(3)</td> </tr> <tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">i</span></code></td> <td><code class="xref c c-type docutils literal notranslate"><span class="pre">int</span></code></td> <td>integer</td> <td>4</td> <td>(3)</td> </tr> <tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">I</span></code></td> <td><code class="xref c c-type docutils literal notranslate"><span class="pre">unsigned</span> <span class="pre">int</span></code></td> <td>integer</td> <td>4</td> <td>(3)</td> </tr> <tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">l</span></code></td> <td><code class="xref c c-type docutils literal notranslate"><span class="pre">long</span></code></td> <td>integer</td> <td>4</td> <td>(3)</td> </tr> <tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">L</span></code></td> <td><code class="xref c c-type docutils literal notranslate"><span class="pre">unsigned</span> <span class="pre">long</span></code></td> <td>integer</td> <td>4</td> <td>(3)</td> </tr> <tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">q</span></code></td> <td><code class="xref c c-type docutils literal notranslate"><span class="pre">long</span> <span class="pre">long</span></code></td> <td>integer</td> <td>8</td> <td>(2), (3)</td> </tr> <tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">Q</span></code></td> <td><code class="xref c c-type docutils literal notranslate"><span class="pre">unsigned</span> <span class="pre">long</span> <span class="pre">long</span></code></td> <td>integer</td> <td>8</td> <td>(2), (3)</td> </tr> <tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">f</span></code></td> <td><code class="xref c c-type docutils literal notranslate"><span class="pre">float</span></code></td> <td>float</td> <td>4</td> <td>(4)</td> </tr> <tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">d</span></code></td> <td><code class="xref c c-type docutils literal notranslate"><span class="pre">double</span></code></td> <td>float</td> <td>8</td> <td>(4)</td> </tr> <tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">s</span></code></td> <td><code class="xref c c-type docutils literal notranslate"><span class="pre">char[]</span></code></td> <td>string</td> <td> </td> <td> </td> </tr> <tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">p</span></code></td> <td><code class="xref c c-type docutils literal notranslate"><span class="pre">char[]</span></code></td> <td>string</td> <td> </td> <td> </td> </tr> <tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">P</span></code></td> <td><code class="xref c c-type docutils literal notranslate"><span class="pre">void</span> <span class="pre">*</span></code></td> <td>integer</td> <td> </td> <td>(5), (3)</td> </tr> </tbody> </table> <p>Notes:</p> <ol class="arabic"> <li><p class="first">The <code class="docutils literal notranslate"><span class="pre">'?'</span></code> conversion code corresponds to the <code class="xref c c-type docutils literal notranslate"><span class="pre">_Bool</span></code> type defined by C99. If this type is not available, it is simulated using a <code class="xref c c-type docutils literal notranslate"><span class="pre">char</span></code>. In standard mode, it is always represented by one byte.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.6.</span></p> </div> </li> <li><p class="first">The <code class="docutils literal notranslate"><span class="pre">'q'</span></code> and <code class="docutils literal notranslate"><span class="pre">'Q'</span></code> conversion codes are available in native mode only if the platform C compiler supports C <code class="xref c c-type docutils literal notranslate"><span class="pre">long</span> <span class="pre">long</span></code>, or, on Windows, <code class="xref c c-type docutils literal notranslate"><span class="pre">__int64</span></code>. They are always available in standard modes.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.2.</span></p> </div> </li> <li><p class="first">When attempting to pack a non-integer using any of the integer conversion codes, if the non-integer has a <a class="reference internal" href="../reference/datamodel.html#object.__index__" title="object.__index__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__index__()</span></code></a> method then that method is called to convert the argument to an integer before packing. If no <a class="reference internal" href="../reference/datamodel.html#object.__index__" title="object.__index__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__index__()</span></code></a> method exists, or the call to <a class="reference internal" href="../reference/datamodel.html#object.__index__" title="object.__index__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__index__()</span></code></a> raises <a class="reference internal" href="exceptions.html#exceptions.TypeError" title="exceptions.TypeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TypeError</span></code></a>, then the <a class="reference internal" href="../reference/datamodel.html#object.__int__" title="object.__int__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__int__()</span></code></a> method is tried. However, the use of <a class="reference internal" href="../reference/datamodel.html#object.__int__" title="object.__int__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__int__()</span></code></a> is deprecated, and will raise <a class="reference internal" href="exceptions.html#exceptions.DeprecationWarning" title="exceptions.DeprecationWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">DeprecationWarning</span></code></a>.</p> <div class="versionchanged"> <p><span class="versionmodified">Changed in version 2.7: </span>Use of the <a class="reference internal" href="../reference/datamodel.html#object.__index__" title="object.__index__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__index__()</span></code></a> method for non-integers is new in 2.7.</p> </div> <div class="versionchanged"> <p><span class="versionmodified">Changed in version 2.7: </span>Prior to version 2.7, not all integer conversion codes would use the <a class="reference internal" href="../reference/datamodel.html#object.__int__" title="object.__int__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__int__()</span></code></a> method to convert, and <a class="reference internal" href="exceptions.html#exceptions.DeprecationWarning" title="exceptions.DeprecationWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">DeprecationWarning</span></code></a> was raised only for float arguments.</p> </div> </li> <li><p class="first">For the <code class="docutils literal notranslate"><span class="pre">'f'</span></code> and <code class="docutils literal notranslate"><span class="pre">'d'</span></code> conversion codes, the packed representation uses the IEEE 754 binary32 (for <code class="docutils literal notranslate"><span class="pre">'f'</span></code>) or binary64 (for <code class="docutils literal notranslate"><span class="pre">'d'</span></code>) format, regardless of the floating-point format used by the platform.</p> </li> <li><p class="first">The <code class="docutils literal notranslate"><span class="pre">'P'</span></code> format character is only available for the native byte ordering (selected as the default or with the <code class="docutils literal notranslate"><span class="pre">'@'</span></code> byte order character). The byte order character <code class="docutils literal notranslate"><span class="pre">'='</span></code> chooses to use little- or big-endian ordering based on the host system. The struct module does not interpret this as native ordering, so the <code class="docutils literal notranslate"><span class="pre">'P'</span></code> format is not available.</p> </li> </ol> <p>A format character may be preceded by an integral repeat count. For example, the format string <code class="docutils literal notranslate"><span class="pre">'4h'</span></code> means exactly the same as <code class="docutils literal notranslate"><span class="pre">'hhhh'</span></code>.</p> <p>Whitespace characters between formats are ignored; a count and its format must not contain whitespace though.</p> <p>For the <code class="docutils literal notranslate"><span class="pre">'s'</span></code> format character, the count is interpreted as the size of the string, not a repeat count like for the other format characters; for example, <code class="docutils literal notranslate"><span class="pre">'10s'</span></code> means a single 10-byte string, while <code class="docutils literal notranslate"><span class="pre">'10c'</span></code> means 10 characters. If a count is not given, it defaults to 1. For packing, the string is truncated or padded with null bytes as appropriate to make it fit. For unpacking, the resulting string always has exactly the specified number of bytes. As a special case, <code class="docutils literal notranslate"><span class="pre">'0s'</span></code> means a single, empty string (while <code class="docutils literal notranslate"><span class="pre">'0c'</span></code> means 0 characters).</p> <p>The <code class="docutils literal notranslate"><span class="pre">'p'</span></code> format character encodes a “Pascal string”, meaning a short variable-length string stored in a <em>fixed number of bytes</em>, given by the count. The first byte stored is the length of the string, or 255, whichever is smaller. The bytes of the string follow. If the string passed in to <a class="reference internal" href="#struct.pack" title="struct.pack"><code class="xref py py-func docutils literal notranslate"><span class="pre">pack()</span></code></a> is too long (longer than the count minus 1), only the leading <code class="docutils literal notranslate"><span class="pre">count-1</span></code> bytes of the string are stored. If the string is shorter than <code class="docutils literal notranslate"><span class="pre">count-1</span></code>, it is padded with null bytes so that exactly count bytes in all are used. Note that for <a class="reference internal" href="#struct.unpack" title="struct.unpack"><code class="xref py py-func docutils literal notranslate"><span class="pre">unpack()</span></code></a>, the <code class="docutils literal notranslate"><span class="pre">'p'</span></code> format character consumes count bytes, but that the string returned can never contain more than 255 characters.</p> <p>For the <code class="docutils literal notranslate"><span class="pre">'P'</span></code> format character, the return value is a Python integer or long integer, depending on the size needed to hold a pointer when it has been cast to an integer type. A <em>NULL</em> pointer will always be returned as the Python integer <code class="docutils literal notranslate"><span class="pre">0</span></code>. When packing pointer-sized values, Python integer or long integer objects may be used. For example, the Alpha and Merced processors use 64-bit pointer values, meaning a Python long integer will be used to hold the pointer; other platforms use 32-bit pointers and will use a Python integer.</p> <p>For the <code class="docutils literal notranslate"><span class="pre">'?'</span></code> format character, the return value is either <a class="reference internal" href="constants.html#True" title="True"><code class="xref py py-const docutils literal notranslate"><span class="pre">True</span></code></a> or <a class="reference internal" href="constants.html#False" title="False"><code class="xref py py-const docutils literal notranslate"><span class="pre">False</span></code></a>. When packing, the truth value of the argument object is used. Either 0 or 1 in the native or standard bool representation will be packed, and any non-zero value will be <code class="docutils literal notranslate"><span class="pre">True</span></code> when unpacking.</p> </div> <div class="section" id="examples"> <span id="struct-examples"></span><h3>7.3.2.3. Examples<a class="headerlink" href="#examples" title="Permalink to this headline">¶</a></h3> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">All examples assume a native byte order, size, and alignment with a big-endian machine.</p> </div> <p>A basic example of packing/unpacking three integers:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">struct</span> <span class="k">import</span> <span class="o">*</span> <span class="gp">>>> </span><span class="n">pack</span><span class="p">(</span><span class="s1">'hhl'</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span> <span class="go">'\x00\x01\x00\x02\x00\x00\x00\x03'</span> <span class="gp">>>> </span><span class="n">unpack</span><span class="p">(</span><span class="s1">'hhl'</span><span class="p">,</span> <span class="s1">'</span><span class="se">\x00\x01\x00\x02\x00\x00\x00\x03</span><span class="s1">'</span><span class="p">)</span> <span class="go">(1, 2, 3)</span> <span class="gp">>>> </span><span class="n">calcsize</span><span class="p">(</span><span class="s1">'hhl'</span><span class="p">)</span> <span class="go">8</span> </pre></div> </div> <p>Unpacked fields can be named by assigning them to variables or by wrapping the result in a named tuple:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">record</span> <span class="o">=</span> <span class="s1">'raymond </span><span class="se">\x32\x12\x08\x01\x08</span><span class="s1">'</span> <span class="gp">>>> </span><span class="n">name</span><span class="p">,</span> <span class="n">serialnum</span><span class="p">,</span> <span class="n">school</span><span class="p">,</span> <span class="n">gradelevel</span> <span class="o">=</span> <span class="n">unpack</span><span class="p">(</span><span class="s1">'<10sHHb'</span><span class="p">,</span> <span class="n">record</span><span class="p">)</span> <span class="gp">>>> </span><span class="kn">from</span> <span class="nn">collections</span> <span class="k">import</span> <span class="n">namedtuple</span> <span class="gp">>>> </span><span class="n">Student</span> <span class="o">=</span> <span class="n">namedtuple</span><span class="p">(</span><span class="s1">'Student'</span><span class="p">,</span> <span class="s1">'name serialnum school gradelevel'</span><span class="p">)</span> <span class="gp">>>> </span><span class="n">Student</span><span class="o">.</span><span class="n">_make</span><span class="p">(</span><span class="n">unpack</span><span class="p">(</span><span class="s1">'<10sHHb'</span><span class="p">,</span> <span class="n">record</span><span class="p">))</span> <span class="go">Student(name='raymond ', serialnum=4658, school=264, gradelevel=8)</span> </pre></div> </div> <p>The ordering of format characters may have an impact on size since the padding needed to satisfy alignment requirements is different:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">pack</span><span class="p">(</span><span class="s1">'ci'</span><span class="p">,</span> <span class="s1">'*'</span><span class="p">,</span> <span class="mh">0x12131415</span><span class="p">)</span> <span class="go">'*\x00\x00\x00\x12\x13\x14\x15'</span> <span class="gp">>>> </span><span class="n">pack</span><span class="p">(</span><span class="s1">'ic'</span><span class="p">,</span> <span class="mh">0x12131415</span><span class="p">,</span> <span class="s1">'*'</span><span class="p">)</span> <span class="go">'\x12\x13\x14\x15*'</span> <span class="gp">>>> </span><span class="n">calcsize</span><span class="p">(</span><span class="s1">'ci'</span><span class="p">)</span> <span class="go">8</span> <span class="gp">>>> </span><span class="n">calcsize</span><span class="p">(</span><span class="s1">'ic'</span><span class="p">)</span> <span class="go">5</span> </pre></div> </div> <p>The following format <code class="docutils literal notranslate"><span class="pre">'llh0l'</span></code> specifies two pad bytes at the end, assuming longs are aligned on 4-byte boundaries:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">pack</span><span class="p">(</span><span class="s1">'llh0l'</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span> <span class="go">'\x00\x00\x00\x01\x00\x00\x00\x02\x00\x03\x00\x00'</span> </pre></div> </div> <p>This only works when native size and alignment are in effect; standard size and alignment does not enforce any alignment.</p> <div class="admonition seealso"> <p class="first admonition-title">See also</p> <dl class="last docutils"> <dt>Module <a class="reference internal" href="array.html#module-array" title="array: Space efficient arrays of uniformly typed numeric values."><code class="xref py py-mod docutils literal notranslate"><span class="pre">array</span></code></a></dt> <dd>Packed binary storage of homogeneous data.</dd> <dt>Module <a class="reference internal" href="xdrlib.html#module-xdrlib" title="xdrlib: Encoders and decoders for the External Data Representation (XDR)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xdrlib</span></code></a></dt> <dd>Packing and unpacking of XDR data.</dd> </dl> </div> </div> </div> <div class="section" id="classes"> <span id="struct-objects"></span><h2>7.3.3. Classes<a class="headerlink" href="#classes" title="Permalink to this headline">¶</a></h2> <p>The <a class="reference internal" href="#module-struct" title="struct: Interpret strings as packed binary data."><code class="xref py py-mod docutils literal notranslate"><span class="pre">struct</span></code></a> module also defines the following type:</p> <dl class="class"> <dt id="struct.Struct"> <em class="property">class </em><code class="descclassname">struct.</code><code class="descname">Struct</code><span class="sig-paren">(</span><em>format</em><span class="sig-paren">)</span><a class="headerlink" href="#struct.Struct" title="Permalink to this definition">¶</a></dt> <dd><p>Return a new Struct object which writes and reads binary data according to the format string <em>format</em>. Creating a Struct object once and calling its methods is more efficient than calling the <a class="reference internal" href="#module-struct" title="struct: Interpret strings as packed binary data."><code class="xref py py-mod docutils literal notranslate"><span class="pre">struct</span></code></a> functions with the same format since the format string only needs to be compiled once.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.5.</span></p> </div> <p>Compiled Struct objects support the following methods and attributes:</p> <dl class="method"> <dt id="struct.Struct.pack"> <code class="descname">pack</code><span class="sig-paren">(</span><em>v1</em>, <em>v2</em>, <em>...</em><span class="sig-paren">)</span><a class="headerlink" href="#struct.Struct.pack" title="Permalink to this definition">¶</a></dt> <dd><p>Identical to the <a class="reference internal" href="#struct.pack" title="struct.pack"><code class="xref py py-func docutils literal notranslate"><span class="pre">pack()</span></code></a> function, using the compiled format. (<code class="docutils literal notranslate"><span class="pre">len(result)</span></code> will equal <code class="xref py py-attr docutils literal notranslate"><span class="pre">self.size</span></code>.)</p> </dd></dl> <dl class="method"> <dt id="struct.Struct.pack_into"> <code class="descname">pack_into</code><span class="sig-paren">(</span><em>buffer</em>, <em>offset</em>, <em>v1</em>, <em>v2</em>, <em>...</em><span class="sig-paren">)</span><a class="headerlink" href="#struct.Struct.pack_into" title="Permalink to this definition">¶</a></dt> <dd><p>Identical to the <a class="reference internal" href="#struct.pack_into" title="struct.pack_into"><code class="xref py py-func docutils literal notranslate"><span class="pre">pack_into()</span></code></a> function, using the compiled format.</p> </dd></dl> <dl class="method"> <dt id="struct.Struct.unpack"> <code class="descname">unpack</code><span class="sig-paren">(</span><em>string</em><span class="sig-paren">)</span><a class="headerlink" href="#struct.Struct.unpack" title="Permalink to this definition">¶</a></dt> <dd><p>Identical to the <a class="reference internal" href="#struct.unpack" title="struct.unpack"><code class="xref py py-func docutils literal notranslate"><span class="pre">unpack()</span></code></a> function, using the compiled format. (<code class="docutils literal notranslate"><span class="pre">len(string)</span></code> must equal <code class="xref py py-attr docutils literal notranslate"><span class="pre">self.size</span></code>).</p> </dd></dl> <dl class="method"> <dt id="struct.Struct.unpack_from"> <code class="descname">unpack_from</code><span class="sig-paren">(</span><em>buffer</em>, <em>offset=0</em><span class="sig-paren">)</span><a class="headerlink" href="#struct.Struct.unpack_from" title="Permalink to this definition">¶</a></dt> <dd><p>Identical to the <a class="reference internal" href="#struct.unpack_from" title="struct.unpack_from"><code class="xref py py-func docutils literal notranslate"><span class="pre">unpack_from()</span></code></a> function, using the compiled format. (<code class="docutils literal notranslate"><span class="pre">len(buffer[offset:])</span></code> must be at least <code class="xref py py-attr docutils literal notranslate"><span class="pre">self.size</span></code>).</p> </dd></dl> <dl class="attribute"> <dt id="struct.Struct.format"> <code class="descname">format</code><a class="headerlink" href="#struct.Struct.format" title="Permalink to this definition">¶</a></dt> <dd><p>The format string used to construct this Struct object.</p> </dd></dl> <dl class="attribute"> <dt id="struct.Struct.size"> <code class="descname">size</code><a class="headerlink" href="#struct.Struct.size" title="Permalink to this definition">¶</a></dt> <dd><p>The calculated size of the struct (and hence of the string) corresponding to <a class="reference internal" href="functions.html#format" title="format"><code class="xref py py-attr docutils literal notranslate"><span class="pre">format</span></code></a>.</p> </dd></dl> </dd></dl> </div> </div> </div> </div> </div> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> <h3><a href="../contents.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">7.3. <code class="docutils literal notranslate"><span class="pre">struct</span></code> — Interpret strings as packed binary data</a><ul> <li><a class="reference internal" href="#functions-and-exceptions">7.3.1. Functions and Exceptions</a></li> <li><a class="reference internal" href="#format-strings">7.3.2. Format Strings</a><ul> <li><a class="reference internal" href="#byte-order-size-and-alignment">7.3.2.1. Byte Order, Size, and Alignment</a></li> <li><a class="reference internal" href="#format-characters">7.3.2.2. Format Characters</a></li> <li><a class="reference internal" href="#examples">7.3.2.3. Examples</a></li> </ul> </li> <li><a class="reference internal" href="#classes">7.3.3. Classes</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="re.html" title="previous chapter">7.2. <code class="docutils literal notranslate"><span class="pre">re</span></code> — Regular expression operations</a></p> <h4>Next topic</h4> <p class="topless"><a href="difflib.html" title="next chapter">7.4. <code class="docutils literal notranslate"><span class="pre">difflib</span></code> — Helpers for computing deltas</a></p> <div role="note" aria-label="source link"> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../_sources/library/struct.rst.txt" rel="nofollow">Show Source</a></li> </ul> </div> <div id="searchbox" style="display: none" role="search"> <h3>Quick search</h3> <div class="searchformwrapper"> <form class="search" action="../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </div> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related" role="navigation" aria-label="related navigation"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="difflib.html" title="7.4. difflib — Helpers for computing deltas" >next</a> |</li> <li class="right" > <a href="re.html" title="7.2. re — Regular expression operations" >previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="https://www.python.org/">Python</a> »</li> <li> <a href="../index.html">Python 2.7.16 documentation</a> » </li> <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li> <li class="nav-item nav-item-2"><a href="strings.html" >7. String Services</a> »</li> </ul> </div> <div class="footer"> © <a href="../copyright.html">Copyright</a> 1990-2019, Python Software Foundation. <br /> The Python Software Foundation is a non-profit corporation. <a href="https://www.python.org/psf/donations/">Please donate.</a> <br /> Last updated on Mar 27, 2019. <a href="../bugs.html">Found a bug</a>? <br /> Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.7.6. </div> </body> </html>