Python String expandtabs() Metode
Voorbeeld
Stel die oortjiegrootte op 2 witspasies:
txt = "H\te\tl\tl\to"
x = txt.expandtabs(2)
print(x)
Definisie en gebruik
Die expandtabs()
metode stel die oortjiegrootte op die gespesifiseerde aantal witspasies.
Sintaksis
string.expandtabs(tabsize)
Parameterwaardes
Parameter | Description |
---|---|
tabsize | Optional. A number specifying the tabsize. Default tabsize is 8 |
Meer voorbeelde
Voorbeeld
Sien die resultaat deur verskillende oortjiegroottes te gebruik:
txt = "H\te\tl\tl\to"
print(txt)
print(txt.expandtabs())
print(txt.expandtabs(2))
print(txt.expandtabs(4))
print(txt.expandtabs(10))