新聞中心
這里有您想知道的互聯網營銷解決方案
創(chuàng)新互聯Python教程:Pythonexpandtabs()方法
描述

創(chuàng)新互聯公司是專業(yè)的呼圖壁網站建設公司,呼圖壁接單;提供網站設計、網站建設,網頁設計,網站設計,建網站,PHP網站建設等專業(yè)做網站服務;采用PHP框架,可快速的進行呼圖壁網站開發(fā)網頁制作和功能擴展;專業(yè)做搜索引擎喜愛的網站,專業(yè)的做網站團隊,希望更多企業(yè)前來合作!
Python expandtabs() 方法把字符串中的 tab 符號('\t')轉為空格,默認的空格數 tabsize 是 8。
語法
expandtabs()方法語法:
string.expandtabs(tabsize=8)
參數
tabsize -- 指定轉換字符串中的 tab 符號('\t')轉為空格的字符數。
返回值
該方法返回字符串中的 tab 符號('\t')轉為空格后生成的新字符串。
實例
以下實例展示了expandtabs()方法的實例:
#!/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)
以上實例輸出結果如下
Original string: this is string example....wow!!! Defualt exapanded tab: this is string example....wow!!! Double exapanded tab: this is string example....wow!!!
標題名稱:創(chuàng)新互聯Python教程:Pythonexpandtabs()方法
本文來源:http://m.fisionsoft.com.cn/article/djeiedo.html


咨詢
建站咨詢
