Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python what does "%ds" mean in format?

Tags:

python-2.7

What does "%ds" in following codes mean?

theline = 'aaaaaeeebbbbbbbbccccccccddd'
baseformat = "5s 3x 8s 8s"
numremain = len(theline) - struct.calcsize(baseformat)
format = "%s %ds" % (baseformat, numremain)
s1, s2, s3, s4= struct.unpack(format, theline)
like image 977
Lancert9 Avatar asked Jun 20 '26 22:06

Lancert9


1 Answers

The '%ds' is not a format specifier. It's '%d' followed by 's':

>>> "%ds" % 6
6s
like image 92
dlask Avatar answered Jun 24 '26 19:06

dlask



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!