新聞中心
描述

創(chuàng)新互聯(lián)公司是專業(yè)的呼圖壁網(wǎng)站建設(shè)公司,呼圖壁接單;提供網(wǎng)站設(shè)計(jì)、網(wǎng)站建設(shè),網(wǎng)頁(yè)設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行呼圖壁網(wǎng)站開(kāi)發(fā)網(wǎng)頁(yè)制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛(ài)的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來(lái)合作!
Python expandtabs() 方法把字符串中的 tab 符號(hào)('\t')轉(zhuǎn)為空格,默認(rèn)的空格數(shù) tabsize 是 8。
語(yǔ)法
expandtabs()方法語(yǔ)法:
string.expandtabs(tabsize=8)
參數(shù)
tabsize -- 指定轉(zhuǎn)換字符串中的 tab 符號(hào)('\t')轉(zhuǎn)為空格的字符數(shù)。
返回值
該方法返回字符串中的 tab 符號(hào)('\t')轉(zhuǎn)為空格后生成的新字符串。
實(shí)例
以下實(shí)例展示了expandtabs()方法的實(shí)例:
#!/usr/bin/python string = "this is\tstring example....wow!!!"; print "Original string: " + string print "Defualt exapanded tab: " + string.expandtabs() print "Double exapanded tab: " + string.expandtabs(16)
以上實(shí)例輸出結(jié)果如下
Original string: this is string example....wow!!! Defualt exapanded tab: this is string example....wow!!! Double exapanded tab: this is string example....wow!!!
網(wǎng)站欄目:創(chuàng)新互聯(lián)Python教程:Pythonexpandtabs()方法
文章鏈接:http://www.5511xx.com/article/djeiedo.html


咨詢
建站咨詢
