<th id="wu2k2"><s id="wu2k2"></s></th> <blockquote id="wu2k2"></blockquote>
  • <tr id="wu2k2"></tr>
  • <samp id="wu2k2"><tbody id="wu2k2"></tbody></samp><samp id="wu2k2"><tbody id="wu2k2"></tbody></samp>
  • 更多精彩內容,歡迎關注:

    視頻號
    視頻號

    抖音
    抖音

    快手
    快手

    微博
    微博

    python string函數

    文檔

    python string函數

    python string函數包括:1、str.capitalize();2、str.upper();3、str.lower();4、str.swapcase();5、str.title();6、str.center()。
    推薦度:
    導讀python string函數包括:1、str.capitalize();2、str.upper();3、str.lower();4、str.swapcase();5、str.title();6、str.center()。

    python string函數是什么?一起來看下吧:

    python string函數包括:

    1、str.capitalize:將原字符串內的首字母轉成大寫,其他部分小寫,再返回新字符串

    print("s.capitalize()?=?{function}"
    s.capitalize()?=?Abcada?a

    2、str.lower:將原字符串的字母轉為小寫

    print("s.lower()?=?{function}".format(function?=?s.lower()))
    s.lower()?=?abcada?a

    3、str.upper:將原字符串的字母轉為大寫

    print("s.upper()?=?{function}".format(function?=?s.upper()))
    s.upper()?=?ABCADA?A

    4、str.swapcase:將原字符串的大寫小寫反轉

    print("s.swapcase()?=?{function}".format(function?=?s.swapcase()))
    s.swapcase()?=?ABCAdA?A

    5、str.title:原字符串內如果有特殊字符(包括數字)連接字母,則將特殊字符后的首個英文字母轉化為大寫形態,并返回新字符串

    print("s2.title()?=?{function}".format(function?=?s2.title()))
    s2.title()?=?123A?Abc?Abcsaa?S

    6、str.center:str.center(寬度,填充字符) 將字符串以居中的格式返回,若寬度值比len(s)小則返回原字符串,填充以從左到右為規則,填充字符的默認值為空格,值可以自己更改

    print("s2.center()?=?{function}".format(function?=?s2.center(19,'&')))
    print("s2.center()?=?{function}".format(function?=?s2.center(20,'&')))
    #s2?=?123a?abc?ABCSAa?s
    s2.center()?=?&123a?abc?ABCSAa?s?
    s2.center()?=?&123a?abc?ABCSAa?s?&

    7、str.expandtabs:str.expandtabs(tabsize = 8) 將原字符串中 以前的字符補滿8位(默認),tabsize的值從0-7即8位,在0-7中任意取值則默認tabsize = 8,此后往上+1,就相當于增加一個空格

    print("s3.expandtabs?={function}".format(function?=?s3.expandtabs()))
    print("s3.expandtabs?={function}".format(function?=?s3.expandtabs(0)))
    print("s3.expandtabs?={function}".format(function?=?s3.expandtabs(5)))
    print("s3.expandtabs?={function}".format(function?=?s3.expandtabs(8)))
    print("s3.expandtabs?={function}".format(function?=?s3.expandtabs(9)))#s3?=?"	as?		b123"
    s3.expandtabs?=????????as??????????????b123
    s3.expandtabs?=as?b123
    s3.expandtabs?=?????as????????b123
    s3.expandtabs?=????????as??????????????b123
    s3.expandtabs?=?????????as

    除了上述舉例的,string函數還有許多實用的函數。

    以上就是小編今天的分享,希望可以幫助到大家。

    文檔

    python string函數

    python string函數包括:1、str.capitalize();2、str.upper();3、str.lower();4、str.swapcase();5、str.title();6、str.center()。
    推薦度:
    為你推薦
    資訊專欄
    熱門視頻
    相關推薦
    python構造函數 python延時函數 debug error怎么解決 python讀取json并解析 python 列表添加 python字典按值的大小排序 python 排序算法 spring boot mysql配置 vue動態綁定style js date加一天 字符轉換成ascii碼 c語言struct用法 java reentrantlock python tkinter教程 js獲取日期 python numpy教程 opencv安裝教程python js獲取隨機數 ubuntu卸載mysql cad的基本命令 python類的繼承 python遞歸函數 python內置函數 python判斷字符串相等 python查看已安裝的包 python強制類型轉換 python input函數怎么用 python類型轉換 python split函數用法 python讀取json python組合數據類型 python查看變量類型 python split函數 c++ template用法 老抽和生抽的區別 拉鏈下滑如何解決 防藍光眼鏡怎么辨別 蔥怎么保存 老姜和生姜的區別 新鮮蘑菇怎么保存
    Top 99这里只精品热在线获取| 91麻豆精品激情在线观看最新| 极品精品国产超清自在线观看| 国产精品自在线拍国产| 国产四虎免费精品视频| 国产精品96久久久久久久| 国产系列高清精品第一页| 91精品久久久久久久久久小网站 | 九九精品久久久久久噜噜| 国产日韩精品一区二区三区| 激情亚洲一区国产精品| 国产精品国产三级国产a| 99久久精品免费视频| 亚洲一区精品无码| 久久国产精品99国产精| 9久久9久久精品| 国产精品你懂的在线播放| 亚洲欧洲美洲无码精品VA| 午夜三级国产精品理论三级| 亚洲精品综合一二三区在线| 国产成人精品视频网站| 欧美精品大香伊蕉在人线| 亚洲精品中文字幕无码AV| 国产天天综合永久精品日| 国产精品自在在线午夜蜜芽tv在线| 999任你躁在线精品免费不卡 | 久久国产精品2020免费m3u8| 国产精品视频1区| 99精品国产高清一区二区| 久久精品国产亚洲av麻豆| 国产成人精品实拍在线| 苍井空亚洲精品AA片在线播放| 日韩精品乱码AV一区二区| 国产成人精品999在线观看| 国产主播福利精品一区二区| 国产91大片精品一区在线观看| 精品少妇无码AV无码专区| 98久久人妻无码精品系列蜜桃| 久热这里只有精品12| 精品人妻系列无码天堂| 亚洲国产精品乱码在线观看97|