Skip to content

Instantly share code, notes, and snippets.

@benosteen
Created March 23, 2017 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benosteen/5a35f9b2fc759e115f18c532d1e5560b to your computer and use it in GitHub Desktop.
Save benosteen/5a35f9b2fc759e115f18c532d1e5560b to your computer and use it in GitHub Desktop.
Some equivalent string formatting things to give you an idea of the basics
"I love {favourite} pie, but hate {hated} ones.".format(favourite = "apple", hated = "pear")
fruit = {"favourite": "apple", "hated": "pear"}
"I love {favourite} pie, but hate {hated} ones.".format(**fruit)
fruit = {"favourite": "apple", "hated": "pear"}
"I love {favourite} pie, but hate {hated} ones.".format(**fruit)
"I love {0} pie, but hate {1} ones.".format("apple", "fruit")
Also, there is number possibilities for formatting too (sig figs etc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment