新聞中心
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)
創(chuàng)新互聯(lián)專業(yè)成都網(wǎng)站建設(shè)、網(wǎng)站設(shè)計,集網(wǎng)站策劃、網(wǎng)站設(shè)計、網(wǎng)站制作于一體,網(wǎng)站seo、網(wǎng)站優(yōu)化、網(wǎng)站營銷、軟文發(fā)布平臺等專業(yè)人才根據(jù)搜索規(guī)律編程設(shè)計,讓網(wǎng)站在運行后,在搜索中有好的表現(xiàn),專業(yè)設(shè)計制作為您帶來效益的網(wǎng)站!讓網(wǎng)站建設(shè)為您創(chuàng)造效益。
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() ##刪除結(jié)尾空白
favorite_language
favorite_language.lstrip() ##刪除開頭空白
favorite_language
favorite_language.strip() ##刪除字符串開頭和結(jié)尾空白
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()) ##刪除結(jié)尾空格
print(famous_person.strip()) ##刪除開頭和結(jié)尾空格
print(famous_person.replace('\n','').replace('\t','')) ##連續(xù)替換\n和\t為空
網(wǎng)站欄目:[python]字符串總結(jié)
文章源于:http://www.dlmjj.cn/article/pdhhoo.html