Monday, May 25, 2009

Single-Quoted Strings and Escaping Quotes :

Strings are values, just as numbers are:

>>> "Hello, world!"

'Hello, world!'

There is one thing that may be a bit surprising about this example, though:

When Python printed out our string, it used single quotes, whereas we used double quotes.

What’s the difference? Actually, there is no difference:

>>> 'Hello, world!'

'Hello, world!'

Here, we use single quotes, and the result is the same. So why allow both?

Because in some cases it may be useful:

>>> "Let's go!"

"Let's go!"

>>> '"Hello, world!" she said'

'"Hello, world!" she said'

No comments:

Data Science - 103 (Kapil Sharma)

Cloud Computing Basic:-  In this the PC is on service provider data center and secuirty maintenance and upgrades are done by the service pro...