mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
A plus is also a sign!
This commit is contained in:
parent
7045dd04d7
commit
333c2e02d0
2 changed files with 4 additions and 4 deletions
|
@ -142,6 +142,6 @@ 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] = '-':
|
if s[0] in ('-', '+'):
|
||||||
sign, s = '-', s[1:]
|
sign, s = s[0], s[1:]
|
||||||
return sign + '0'*(width-n) + s
|
return sign + '0'*(width-n) + s
|
||||||
|
|
|
@ -142,6 +142,6 @@ 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] = '-':
|
if s[0] in ('-', '+'):
|
||||||
sign, s = '-', 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