Methods :
s = "hello world"
s.upper() # 'HELLO WORLD'
s.lower() # 'hello world'
s.capitalize() # 'Hello world'
s.title() # 'Hello World'
s.strip() # Remove whitespace
s.lstrip() # Left-strip
s.rstrip() # Right-strip
s.replace("l", "x") # 'hexxo worxd'
s.split(" ") # ['hello', 'world']
s.join(['a', 'b']) # 'a b'
s.startswith("he") # True
s.endswith("ld") # True
s.find("o") # First index (4)
s.rfind("o") # Last index (7)
s.count("l") # 3
s.isalpha() # False
s.isdigit() # False
s.isalnum() # False
s.islower() # True
s.isupper() # False
s.swapcase() # 'HELLO WORLD'
s.zfill(12) # '00hello world'
s.center(20, "-") # '----hello world-----'
No comments:
Post a Comment