monica_b1998@lemmy.world to Python@programming.dev · 2 days agoPython String Formatting: f-strings vs .format() vs %slicker.meexternal-linkmessage-square12linkfedilinkarrow-up139arrow-down10
arrow-up139arrow-down1external-linkPython String Formatting: f-strings vs .format() vs %slicker.memonica_b1998@lemmy.world to Python@programming.dev · 2 days agomessage-square12linkfedilink
minus-squareitsathursday@lemmy.worldlinkfedilinkarrow-up4·2 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·2 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