mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Fix PR#31 -- zfill() mishandles empty string.
This commit is contained in:
parent
42636dc64d
commit
1b7aec35c4
1 changed files with 1 additions and 1 deletions
|
@ -475,7 +475,7 @@ def zfill(x, width):
|
||||||
n = len(s)
|
n = len(s)
|
||||||
if n >= width: return s
|
if n >= width: return s
|
||||||
sign = ''
|
sign = ''
|
||||||
if s[0] in ('-', '+'):
|
if s[:1] in ('-', '+'):
|
||||||
sign, s = s[0], s[1:]
|
sign, s = s[0], s[1:]
|
||||||
return sign + '0'*(width-n) + s
|
return sign + '0'*(width-n) + s
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue