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)
創新互聯專業成都網站建設、網站設計,集網站策劃、網站設計、網站制作于一體,網站seo、網站優化、網站營銷、軟文發布平臺等專業人才根據搜索規律編程設計,讓網站在運行后,在搜索中有好的表現,專業設計制作為您帶來效益的網站!讓網站建設為您創造效益。
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為空
網站欄目:[python]字符串總結
標題網址:http://vcdvsql.cn/article0/pdhhoo.html
成都網站建設公司_創新互聯,為您提供商城網站、網站導航、品牌網站建設、網站建設、動態網站、小程序開發
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯