abc
输出:abc00000
width
:指定字符串长度。fillchar
:填充字符,默认为空格。try:while True:s = input()while len(s):print(s[:8].ljust(8, '0'))s = s[8:]
except EOFError:pass
:0
:数字补0 (填充右边)
<
:左对齐
8s
:占位符8位
:0<8s
右补零,左对齐,占8位
try:while True:s = input()for i in range(0, len(s), 8):print('{:0<8s}'.format(s[i:i+8]))
except EOFError:pass
try:while True:s = input()length = len(s)if not length % 8 == 0:for i in range(8 - length % 8):s += '0'cnt = 0for i in s:cnt += 1if not cnt % 8:print(i)else:print(i, end='', sep='')
except EOFError:pass
while True:try:cnt = 0for i in input():if cnt % 8 == 0 and cnt:print()print(i, sep='', end='')cnt += 1zN = 8 - cnt % 8if zN == 8:continuefor i in range(zN):print('0', sep='', end='')print()except EOFError:break
本文发布于:2024-01-29 16:08:37,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170651571816476.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |