修改字符串大小写

name = "ada lovelace"
print(name.title())
Ada Lovelace
name2 = "Ada Lovelace"
print(name2.upper())
ADA LOVELACE
print(name2.lower())
ada lovelace
firstname = "ada"
lastname = "lovelace"
fullname = firstname+" "+lastname
print(fullname)
ada lovelace
print(fullname.title())
Ada Lovelace
print("Hello,"+fullname.title()+"!")
Hello,Ada Lovelace!
print("\tpython")
    python
 
  
>>> message="langueages:\nPython\nC\nJavaScript"
>>> print(message)
langueages:
Python
C
JavaScript
>>> message="python "
>>> message
'python '
>>> message.rstrip()
'python'
>>> message
'python '
>>> hehe = " python "
>>> hehe
' python '
>>> hehe.rstrip()
' python'
>>> hehe.lstrip()
'python '
>>> hehe.strip()
'python'
>>> hehe.rstrip()
' python'
 
   
   
 
  
 

猜你喜欢

转载自www.cnblogs.com/puyitian/p/10122646.html