Introducing Python © Chirag Wazir 2002 Prev   Index   Next

Strings

raw & unicode strings

"""This is a somewhat
long string"""
print "Hello " + "World"    # Hello World
print '$' * 10              # $$$$$$$$$$
print "c:\temp"             # c:    emp
print r"c:\temp"            # c:\temp
len('Python')               # 6
"a,b,c,d".split(',') # ['a', 'b', 'c', 'd'] ';'.join(['a','b','c']) # 'a;b;c' "some test text".replace('te', 'xyz') #'some xyzst xyzxt' "hello world".count('l') # 3 " python ".upper().strip() # 'PYTHON'