string - In Python, can you have variables within triple quotes? If so, how? -


this simple question some, has me stumped. can use variables within python's triple-quotes?

in following example, how use variables in text:

wash_clothes = 'tuesdays' clean_dishes = 'never'  mystring =""" wash clothes on %wash_clothes clean dishes %clean_dishes """  print(mystring) 

i result in:

 wash clothes on tuesdays      clean dishes never 

if not best way handle large chunks of text need couple variables, , there ton of text , special characters?

one of ways :

>>> mystring =""" wash clothes on %s ... clean dishes %s ... """ >>> wash_clothes = 'tuesdays' >>> clean_dishes = 'never' >>>  >>> print mystring % (wash_clothes, clean_dishes)  wash clothes on tuesdays clean dishes never 

also @ string formatting


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -