Python String - UNIT 3
Python String - UNIT 3
Python String - UNIT 3
String are stored in continuous memory location % Format - Performs String See at next
formatting section
Format Conversion
Symbol
%c character
String Special Operators
comparison operator
All Relational operator (< <= > >= == != )apply on string 5.isalnum() :The method isalnum() checks whether the string
also consists of alphanumeric characters.
1. capitalize() It returns a copy of the string with only its first Return Value
character capitalized. This method returns true if all characters in the string are
Return value : String alphanumeric and there is at least one character, false
Argument type :NA otherwise.
str = "this is string example. ..wow!!!"; str = "this2009"; # No space in this string
print "str.capitalize() : str = "this is string example. .. wow!!!"; print str.isalnum()
output
str = "this is string example. .. wow!!!";
str.capitalize() : This is string example. .. wow!!! print str.isalnum()
Syntax : str.find(str, beg=0, end=len(string)) isalpha() The method checks whether the string consists of
str − This specifies the string to be searched. alphabetic characters only.
beg − This is the starting index, by default its 0.
end − This is the ending index, by default its equal to the Syntax: str.isalpha()
length of the string.
str = "123456"; # not work with space str = "This is string example. .. wow!!!";
print str.isdigit() print str.isspace()
this is string example. .. wow!!! The following diagram depicts how the string modulo
88888888this is string example... wow!!! operator works:
str.strip([chars]);
split() The split() method splits a string into a list. The format string contains placeholders. There are two of
those in our example: "%5d" and "%8.2f".
You can specify the separator, default separator is any
whitespace. The general syntax for a format placeholder is
string.split(separator, max)
Let's have a look at the placeholders in our example
str.split(str="", num=string.count(str)). This is followed by the total number of digits the string
should contain. This number includes the decimal point and
all the digits. i.e. before and after the decimal point.
Parameter Description