Skip to content

Python kitchen

Always cooking something nice!

  • contact us
language core

handling curly braces in string formatting – python

May 9, 2018 Abdur-Rahmaan Janhangeer

let us say you want to print :

{text}

using

'{ {} }'.format(content)

how to escape the {}?

'\{ {} \}'.format(content)

works not

the answer

the answer is to double curly braces like that :

'{{ {} }}'.format(content)

simple !

Similar Posts

String Manipulation Functions: The Top 5 You Forgot To Pack

String Manipulation Functions: The Top 5 You Forgot To Pack

July 22, 2019July 22, 2019 Abdur-Rahmaan Janhangeer

Post navigation

Previous home machine learning project : identifying cutlery items
Next events introduced : live coding class

NEWSLETTER

Loading

RECENTLY

  • Machine Learning Part 12 Association Analysis
  • Machine Learning Part 11 Unpervised Learning
  • Machine Learning Part 10 Naive Bayes
  • Machine Learning Part 9 Neural Networks
  • Machine Learning Part 8: Support Vector Machines

PAGES

  • about me
  • contact us
  • data usage policy
  • lightweight learn python book

CATEGORIES

  • algorithm and data structures
  • announcements
  • blog presence
  • book review
  • books
  • canvas theory
  • chatbot
  • compiler theory
  • computer vision
  • courses
  • daily coding problem
  • data science
  • docs
  • editors and ides
  • flask
  • games
  • generators
  • geospatial
  • git
  • gui
  • hooman
  • interview
  • language core
  • machine learning
  • oop
  • packaging & distribution
  • pandas
  • processing.py
  • programming problems
  • projects
  • pygame
  • pyqt5
  • pyside
  • raspberry pi
  • realtime
  • regex
  • security
  • shopyo
  • standard library
  • string
  • Uncategorized
  • vids
  • virtual environment
  • zen

Newsletter Signup

WordPress Theme: BlogGrid by TwoPoints.