修改字符串大小写
Posted puyitian
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了修改字符串大小写相关的知识,希望对你有一定的参考价值。
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(" python") python
>>> message="langueages: Python C javascript" >>> 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‘
以上是关于修改字符串大小写的主要内容,如果未能解决你的问题,请参考以下文章