fixed width numbers - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: fixed width numbers (/thread-18651.html) Pages:
1
2
|
RE: fixed width numbers - Larz60+ - May-26-2019 Nwb's method is the proper one. RE: fixed width numbers - Skaperen - May-27-2019 (May-26-2019, 06:33 PM)Larz60+ Wrote: Nwb's method is the proper one. how can i put an expression in that method? perfringo's method is obvious. RE: fixed width numbers - Larz60+ - May-27-2019 For example? Do you mean like: print(f'Number with leading zeroes{10:020}')
RE: fixed width numbers - Skaperen - May-27-2019 no. can i do this? print(f'foo is{numbers["foo"]**powers["bar"]:20}')it doesn't work in any form in my older Python 3.5.2. was f'' added in 3.6 or 3.7 ? RE: fixed width numbers - perfringo - May-27-2019 (May-27-2019, 07:53 AM)Skaperen Wrote: was f'' added in 3.6 or 3.7 ? Yep, you need 3.6 <= Python RE: fixed width numbers - Skaperen - May-27-2019 then my only choice is your rjust() suggestion which i have already coded. i try to make my code work as far back as 3.3 if it's easy enough, else 3.4 or 3.5. but 3.5.2 is a must, partly because i have run into issues with Ubuntu 18.04 (sudo to root to run bash on amd64 arch fails to source .bashrc file ... it works OK on arm64). |