码迷,mamicode.com
首页 > 编程语言 > 详细

python之再学习----简单的字符串

时间:2018-02-23 22:17:20      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:not   log   test   person   首字母   gpo   转义   day   name   

print("today is 2018.2.22")
name = ‘SUPer‘
print(‘hello,‘+name+‘ today is good or not?‘)
# 全部都是小写 string.lower()
print(name.lower())
# 全部都是大写 string.upper
print(name.upper())
# 首字母是大写 string.title
print(name.title())
# 用三个‘‘‘ ‘‘‘可以让‘ ‘‘转义
print(‘‘‘Alert said,"a person who never made a mistake never tried anything new."‘‘‘)

famous_person = ‘Alert said,"a person who never made a mistake never tried anything new."‘
message = famous_person + ‘balabala‘
print(message)

testname = r‘ super\tsu ha\nha ‘
print(testname.lstrip())
print(testname.rstrip())
print(testname.strip())

直接贴代码,以后遇见好的还会继续补充

python之再学习----简单的字符串

标签:not   log   test   person   首字母   gpo   转义   day   name   

原文地址:https://www.cnblogs.com/superblog/p/8463300.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!