<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 亚洲国产成人精品不卡青青草原 | 精品久久久久久中文字幕女| 国产成人精品综合久久久久| 国产精品久久久久久久| 久久久精品2019中文字幕2020| 国产精品一线二线三线| 91人前露出精品国产| 真实国产乱子伦精品视频| 国产揄拍国内精品对白| 国产精品久久久久久麻豆一区| 久久夜色精品国产亚洲| 国产精品白丝AV嫩草影院| 欧亚精品一区三区免费| 91精品成人免费国产片| 九九热在线视频观看这里只有精品| 精品小视频在线观看| 精品人人妻人人澡人人爽牛牛| 亚洲精品第一国产综合精品| 久久免费国产精品一区二区| 精品久久久久久99人妻| 最新国产精品好看的国产精品| 精品卡一卡二卡乱码高清| 久久国产精品二区99| 三级精品视频在线播放| 国产高清在线精品一区二区三区| 欧洲精品码一区二区三区| 宅男宅女精品国产av天堂| 精品成人A区在线观看| 99国产精品免费观看视频| 久久精品国产只有精品2020| 久久国产精品免费一区| HEYZO无码综合国产精品227| 国产精品二区在线| 精品国产_亚洲人成在线| 日本精品人妻无码免费大全 | 国产精品久久久久久久久电影网| 欧美精品黑人粗大视频 | 国产精品特黄毛片| 尤物精品视频一区二区三区| 一本色道久久88—综合亚洲精品 | 乱色精品无码一区二区国产盗|