Python Forum
changing { and } in str.format()
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
changing { and } in str.format()
#1
i have a bunch of generated strings (read from a file) that are being processed in my script by str.format() with a bunch of args. today, i ran into a case where i have a '{' in one of the strings and str.format() is upset by it. the normal solution with str.format is '{'->'{{'. but this is turning out to be impossible to do because all the '{' are being doubled. what i can do, easily, is have the various '{}' and '{foo}' that are being added changed to something else like maybe '[]' and '[foo]' (i will need to grep this data a few times to see what i can safely pick).

is there a way to have str.format() use an alternate for '{}' and '{foo}'?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
changing { and } in str.format() - by Skaperen - May-11-2019, 12:07 AM
RE: changing { and } in str.format() - by Larz60+ - May-11-2019, 02:50 PM
RE: changing { and } in str.format() - by Skaperen - May-12-2019, 04:58 AM
RE: changing { and } in str.format() - by Skaperen - May-12-2019, 08:44 PM
RE: changing { and } in str.format() - by Skaperen - May-13-2019, 06:32 PM
RE: changing { and } in str.format() - by Skaperen - May-16-2019, 05:07 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Issue in changing data format (2 bytes) into a 16 bit data. GiggsB 11 5,139 Jul-25-2022, 03:19 PM
Last Post: deanhystad
  changing format to Int Scott 3 3,289 Jun-19-2019, 06:33 AM
Last Post: ODIS
  Changing Number Format moby 4 6,264 May-24-2019, 11:04 PM
Last Post: snippsat
  Date Format Changing Program Not Working pyth0nus3r 2 5,974 Jan-28-2017, 10:34 PM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020