Besides numbers, Python can also manipulate strings, which can be expressed in several ways. They can be enclosed in single quotes ( '...' ) or double quotes ( "..." ) with the same result [2] . \ can be used to escape quotes: >>> 'spam eggs' # single quotes 'spam eggs' >>> 'doesn \' t' # use \' to escape the single quote... "doesn't" >>> "doesn't" # ...or use double quotes instead "doesn't" >>> '"Yes," he said.' '"Yes," he said.' >>> " \" Yes, \" he said." '"Yes," he said.' >>> '"Isn \' t," she said.' '"Isn\'t," she said.' If you don’t want characters prefaced with \ to be interpreted as special characters, you can use raw strings by adding an r before the first quote: >>>...
Comments
Post a Comment