开发者

% operator in python over string

开发者 https://www.devze.com 2022-12-08 11:49 出处:网络
What does the following Python statement mean开发者_StackOverflow? send_data=\"\" str_len = \"%#04d\" % (len(send_data)/2)

What does the following Python statement mean开发者_StackOverflow?

send_data=""
str_len = "%#04d" % (len(send_data)/2)


This sets str_len to show half the length of send_data, padded with zeros to be four characters right. The % character is carrying out interpolation. See the printf-style String Formatting section of the documentation.

0

精彩评论

暂无评论...
验证码 换一张
取 消