expandtabs Python3 () metode
deskripsi
expandtabs () metode untuk simbol tab string ( '\ t') ke ruang angkasa, tab simbol ( '\ t') adalah nomor standar ruang 8.
tatabahasa
expandtabs () sintaks metode:
str.expandtabs(tabsize=8)
parameter
- tabsize - tentukan tab string konversi simbol ( '\ t') menjadi karakter ruang.
Kembali Nilai
Metode generasi string baru mengembalikan simbol tab string ( '\ t') ke ruang angkasa setelah.
contoh
Contoh berikut menunjukkan contoh expandtabs () metode:
#!/usr/bin/python3 str = "this is\tstring example....wow!!!" print ("原始字符串: " + str) print ("替换 \\t 符号: " + str.expandtabs()) print ("使用16个空格替换 \\t 符号: " + str.expandtabs(16))
Contoh hasil output di atas adalah sebagai berikut:
原始字符串: this is string example....wow!!! 替换 \t 符号: this is string example....wow!!! 使用16个空格替换 \t 符号: this is string example....wow!!!