温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

[python]字符串总结

发布时间:2020-06-03 19:07:13 来源:网络 阅读:277 作者:望天儿先生 栏目:编程语言

1
message1="I love you ,China!"
print(message1)
message2="wO aI ni zhong guo"
print(message2.title()) ##首字母大写
print(message2.upper()) ##字符串全部大写
print(message2.lower()) ##字符串全部小写
message3=message1.title()+" "+message2.upper() ##字符串拼接
print(message3)

2
print("\tleslie") ##/t制表符
print("language:\nchinese\nenglish\njanpanese") ##换行符
print("language:\n\tchinese\t\nenglish\n\tjanpanese") ##制表符和换行符混用

3
favorite_language = ' python '
favorite_language
favorite_language.rstrip() ##删除结尾空白
favorite_language
favorite_language.lstrip() ##删除开头空白
favorite_language
favorite_language.strip() ##删除字符串开头和结尾空白

4
name1=input("name1:")
print("hello "+name1+",would you like to learn some python today?")

5
name1=input("name1:")
print(name1.lower())
print(name1.upper())
print(name1.title())

6
print('Albert Einstein once said,"A person who never made a mistake never tried anything new."')

7
famous_person = input("famous_person:") ##输入一个变量
print(famous_person.title()+' once said,"A person who never made a mistake never tried anything new."')

8
famous_person = "\txu\nlijian\thaha\nhaha\t"
print(famous_person)
print(famous_person.lstrip()) ##删除开头空格
print(famous_person.rstrip()) ##删除结尾空格
print(famous_person.strip()) ##删除开头和结尾空格
print(famous_person.replace('\n','').replace('\t','')) ##连续替换\n和\t为空

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI