What is Python String and how to create String

String literal

In Python the string value is created with quotation marks.

We can use both single-Quotes and double Quotes.


print "Hello, world!" 
print 'Hello, world!' 

The code above generates the following result.

We can even mix the quotes. Quotation inside a quotation


print 'knight"s', "knight's"
print "Let's go!"
print '"Hello, world!" she said'
title = "Meaning " 'of' " Life"
print title# from w  w  w.j  a v a2s .c  om

The code above generates the following result.

Unicode Strings

We can create a unicode string by append u to the string literal.


print u'Hello, world!' 

The code above generates the following result.





















Home »
  Python »
    Data Types »




Data Types
String
String Format
Tuple
List
Set
Dictionary