Related:
Examples | name = "Mr Burns" | Description | Assigns a value to a variable which is a string. Strings are created using quotes - either " or '. If you wish to include a large amount of text with line breaks you can use triple quotes """
Strings have various methods associated with them - see sequence types and string methods. Strings can be sliced using the [x:y] operator. | Syntax | name = value | Parameters | name - a legal variable name (must start with a letter, and can have numbers and underscores in them)
value - the value to store in the variable, in this case a string | Interpreter | Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> name = "Mr. Burns" >>> type(name) <type 'str'> >>> age = '60' >>> type(age) <type 'str'> >>> lotsoftext = """ this is text has ... a line break in it""" >>> lotsoftext ' this is text has\na line break in it' >>> name.lower() 'mr. burns' >>> |
|
|