Can you have variables within triple quotes? If so, how?

The preferred way of doing this is using str.format() rather than the method using %:

This method of string formatting is the new standard in Python 3.0, and should be preferred to the % formatting described in String Formatting Operations in new code.

Example:

wash_clothes="tuesdays"
clean_dishes="never"

mystring =""" I like to wash clothes on {0}
I like to clean dishes {1}
"""

print mystring.format(wash_clothes, clean_dishes)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)