monica_b1998@lemmy.world to Python@programming.dev · 2 months 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 · 2 months agomessage-square15linkfedilink
minus-squareitsathursday@lemmy.worldlinkfedilinkarrow-up4arrow-down1·2 months 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·2 months 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