monica_b1998@lemmy.world to Python@programming.dev · 17 days agoPython String Formatting: f-strings vs .format() vs %slicker.meexternal-linkmessage-square15linkfedilinkarrow-up142arrow-down10
arrow-up142arrow-down1external-linkPython String Formatting: f-strings vs .format() vs %slicker.memonica_b1998@lemmy.world to Python@programming.dev · 17 days agomessage-square15linkfedilink
minus-squareitsathursday@lemmy.worldlinkfedilinkarrow-up4·17 days agoWhat annoyed me moving from % to format was the loss of “formatting” floats to integers with “{:d}”, now you get a ValueError
minus-squareZoteTheMighty@lemmy.ziplinkfedilinkarrow-up5·17 days ago{:.0f} always works though for floats or ints
What annoyed me moving from % to format was the loss of “formatting” floats to integers with “{:d}”, now you get a ValueError
{:.0f}always works though for floats or intsAh nice one