Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ad3882a

Browse files
committed
Fix closes Issue11436 - Minor clarification to struct documentation for 's' format character.
1 parent 0b44795 commit ad3882a

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

Doc/library/struct.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,11 @@ not contain whitespace though.
240240
For the ``'s'`` format character, the count is interpreted as the length of the
241241
bytes, not a repeat count like for the other format characters; for example,
242242
``'10s'`` means a single 10-byte string, while ``'10c'`` means 10 characters.
243-
For packing, the string is truncated or padded with null bytes as appropriate to
244-
make it fit. For unpacking, the resulting bytes object always has exactly the
245-
specified number of bytes. As a special case, ``'0s'`` means a single, empty
246-
string (while ``'0c'`` means 0 characters).
243+
If a count is not given, it defaults to 1. For packing, the string is
244+
truncated or padded with null bytes as appropriate to make it fit. For
245+
unpacking, the resulting bytes object always has exactly the specified number
246+
of bytes. As a special case, ``'0s'`` means a single, empty string (while
247+
``'0c'`` means 0 characters).
247248

248249
When packing a value ``x`` using one of the integer formats (``'b'``,
249250
``'B'``, ``'h'``, ``'H'``, ``'i'``, ``'I'``, ``'l'``, ``'L'``,

0 commit comments

Comments
 (0)