<sup id="m40ya"></sup>
  • 
    
  • <kbd id="m40ya"></kbd>
    <samp id="m40ya"></samp>
    <ul id="m40ya"></ul>
  • 更多精彩內容,歡迎關注:

    視頻號
    視頻號

    抖音
    抖音

    快手
    快手

    微博
    微博

    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 精品无码无人网站免费视频| 免费精品久久久久久中文字幕| 国产亚洲精品福利在线无卡一| 亚洲精品无码av片| 亚洲国产成人精品不卡青青草原| 国产成人亚洲精品91专区手机| 狠狠精品干练久久久无码中文字幕| 99久久精品国产片久人| 亚洲精品一品区二品区三品区| 精品91一区二区三区| 糖心vlog精品一区二区三区| 97国产精品视频观看一| 久久九九亚洲精品| HEYZO无码综合国产精品227| 图片区精品综合自拍| 亚洲男人的天堂久久精品| 久久的精品99精品66| 一夲道无码人妻精品一区二区| 亚洲成人国产精品| 国产在线观看91精品不卡| 国语自产精品视频在线完整版 | 久热这里只精品99国产6_99| 国产精品高清在线| caoporn国产精品免费| 成人国产精品视频频| 欧美日韩精品乱国产| 97久久国产亚洲精品超碰热| 精品无码无人网站免费视频| 少妇人妻偷人精品无码视频新浪 | 久久99热只有频精品8| 久久91精品国产99久久yfo| 久久精品成人国产午夜| 9久久这里只有精品国产| 国产精品青青在线观看爽香蕉| 午夜亚洲av永久无码精品| 青娱乐精品视频在线观看| 国产一区二区三区国产精品| 国产精品无码一区二区三区在| 国产精品青草久久| 男女男精品网站免费观看| 四虎永久在线精品国产馆V视影院|