Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
cf0fb8bf
Kaydet (Commit)
cf0fb8bf
authored
Tem 23, 1998
tarafından
Fred Drake
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Document the 'p' format character.
Clean up some of the markup.
üst
c457ca7e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
7 deletions
+16
-7
libstruct.tex
Doc/lib/libstruct.tex
+16
-7
No files found.
Doc/lib/libstruct.tex
Dosyayı görüntüle @
cf0fb8bf
...
@@ -55,6 +55,7 @@ and Python values should be obvious given their types:
...
@@ -55,6 +55,7 @@ and Python values should be obvious given their types:
\lineiii
{
f
}{
float
}{
float
}
\lineiii
{
f
}{
float
}{
float
}
\lineiii
{
d
}{
double
}{
float
}
\lineiii
{
d
}{
double
}{
float
}
\lineiii
{
s
}{
char[]
}{
string
}
\lineiii
{
s
}{
char[]
}{
string
}
\lineiii
{
p
}{
char[]
}{
string
}
\end{tableiii}
\end{tableiii}
A format character may be preceded by an integral repeat count; e.g.
\
A format character may be preceded by an integral repeat count; e.g.
\
...
@@ -63,7 +64,7 @@ the format string \code{'4h'} means exactly the same as \code{'hhhh'}.
...
@@ -63,7 +64,7 @@ the format string \code{'4h'} means exactly the same as \code{'hhhh'}.
Whitespace characters between formats are ignored; a count and its
Whitespace characters between formats are ignored; a count and its
format must not contain whitespace though.
format must not contain whitespace though.
For the
\c
ode
{
's'
}
format character, the count is interpreted as the
For the
\c
haracter
{
s
}
format character, the count is interpreted as the
size of the string, not a repeat count like for the other format
size of the string, not a repeat count like for the other format
characters; e.g.
\code
{
'10s'
}
means a single 10-byte string, while
characters; e.g.
\code
{
'10s'
}
means a single 10-byte string, while
\code
{
'10c'
}
means 10 characters. For packing, the string is
\code
{
'10c'
}
means 10 characters. For packing, the string is
...
@@ -72,7 +73,15 @@ For unpacking, the resulting string always has exactly the specified
...
@@ -72,7 +73,15 @@ For unpacking, the resulting string always has exactly the specified
number of bytes. As a special case,
\code
{
'0s'
}
means a single, empty
number of bytes. As a special case,
\code
{
'0s'
}
means a single, empty
string (while
\code
{
'0c'
}
means 0 characters).
string (while
\code
{
'0c'
}
means 0 characters).
For the
\code
{
'I'
}
and
\code
{
'L'
}
format characters, the return
The
\character
{
p
}
format character can be used to encode a Pascal
string. The first byte is the length of the stored string, with the
bytes of the string following. If count is given, it is used as the
total number of bytes used, including the length byte. If the string
passed in to
\function
{
pack()
}
is too long, the stored representation
is truncated. If the string is too short, padding is used to ensure
that exactly enough bytes are used to satisfy the count.
For the
\character
{
I
}
and
\character
{
L
}
format characters, the return
value is a Python long integer.
value is a Python long integer.
By default, C numbers are represented in the machine's native format
By default, C numbers are represented in the machine's native format
...
@@ -91,7 +100,7 @@ according to the following table:
...
@@ -91,7 +100,7 @@ according to the following table:
\lineiii
{
!
}{
network (= big-endian)
}{
standard
}
\lineiii
{
!
}{
network (= big-endian)
}{
standard
}
\end{tableiii}
\end{tableiii}
If the first character is not one of these,
\c
ode
{
'@'
}
is assumed.
If the first character is not one of these,
\c
haracter
{
@
}
is assumed.
Native byte order is big-endian or little-endian, depending on the
Native byte order is big-endian or little-endian, depending on the
host system (e.g. Motorola and Sun are big-endian; Intel and DEC are
host system (e.g. Motorola and Sun are big-endian; Intel and DEC are
...
@@ -105,16 +114,16 @@ for any type (so you have to use pad bytes); short is 2 bytes; int and
...
@@ -105,16 +114,16 @@ for any type (so you have to use pad bytes); short is 2 bytes; int and
long are 4 bytes. Float and double are 32-bit and 64-bit IEEE floating
long are 4 bytes. Float and double are 32-bit and 64-bit IEEE floating
point numbers, respectively.
point numbers, respectively.
Note the difference between
\c
ode
{
'@'
}
and
\code
{
'='
}
: both use native
Note the difference between
\c
haracter
{
@
}
and
\character
{
=
}
: both use native
byte order, but the size and alignment of the latter is standardized.
byte order, but the size and alignment of the latter is standardized.
The form
\c
ode
{
'!'
}
is available for those poor souls who claim they
The form
\c
haracter
{
!
}
is available for those poor souls who claim they
can't remember whether network byte order is big-endian or
can't remember whether network byte order is big-endian or
little-endian.
little-endian.
There is no way to indicate non-native byte order (i.e. force
There is no way to indicate non-native byte order (i.e. force
byte-swapping); use the appropriate choice of
\c
ode
{
'<'
}
or
byte-swapping); use the appropriate choice of
\c
haracter
{
<
}
or
\c
ode
{
'>'
}
.
\c
haracter
{
>
}
.
Examples (all using native byte order, size and alignment, on a
Examples (all using native byte order, size and alignment, on a
big-endian machine):
big-endian machine):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment