日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
創(chuàng)新互聯(lián)Python教程:Python expandtabs()

python 中的expandtabs()函數(shù)有助于將字符串中的' \t '字符替換為空格。該函數(shù)允許指定所需的空間量。最后,修改后的字符串作為輸出返回。

濰城ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場(chǎng)景,ssl證書未來市場(chǎng)廣闊!成為創(chuàng)新互聯(lián)公司的ssl證書銷售渠道,可以享受市場(chǎng)價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:13518219792(備注:SSL證書合作)期待與您的合作!

**string.expandtabs(tabsize)** #where tabsize is an integer value

expandtabs()參數(shù):

expandtabs()函數(shù)接受一個(gè)參數(shù)。如果我們需要替換多個(gè)制表符,那么制表符之前的字符只有在到達(dá)前一個(gè)制表符時(shí)才被計(jì)數(shù)。

參數(shù)描述必需/可選
tabsize指定 tabsize 的數(shù)字。默認(rèn) tabsize 為 8可選擇的

expandtabs()返回值

返回值始終是字符串。它返回使用空格擴(kuò)展后的原始字符串的副本。

| 投入 | 返回值 | | 線 | 帶有空格的字符串 |

Python 中expandtabs()方法的示例

示例 1:如何在沒有參數(shù)的情況下使用expandtabs()?

 string = 'abc\t56789\tefg'

# no argument is passed
# default tabsize is 8
result = string.expandtabs()

print(result) 

輸出:

 abc     56789   efg

示例 2:如何用不同的參數(shù)擴(kuò)展?

 string = "abc\t56789\tdef"
print('Original String:', str)

# tabsize is set to 2
print('Expanded tabsize 2:', string.expandtabs(2))

# tabsize is set to 3
print('Expanded tabsize 3:', string.expandtabs(3))

# tabsize is set to 4
print('Expanded tabsize 4:', string.expandtabs(4))

# tabsize is set to 5
print('Expanded tabsize 5:', string.expandtabs(5))

# tabsize is set to 6
print('Expanded tabsize 6:', string.expandtabs(6)) 

輸出:

 Original String: abc 56789 def
Expanded tabsize 2: abc 56789 def
Expanded tabsize 3: abc   56789 def
Expanded tabsize 4: abc 56789   def
Expanded tabsize 5: abc  56789     def
Expanded tabsize 6: abc   56789 def

當(dāng)前標(biāo)題:創(chuàng)新互聯(lián)Python教程:Python expandtabs()
網(wǎng)站網(wǎng)址:http://m.5511xx.com/article/cdjcoog.html