Latest web development tutorials

expandtabs python3 méthode ()

string python3 string python3


description

méthode expandtabs () sur le symbole de l'onglet chaîne ( '\ t') dans l'espace, symbole de tabulation ( '\ t') est le numéro par défaut des espaces 8.

grammaire

méthode expandtabs () Syntaxe:

str.expandtabs(tabsize=8)

Paramètres

  • tabsize - spécifier le symbole de tabulation de chaîne de conversion ( '\ t') en caractères d'espace.

Valeur de retour

La nouvelle méthode de génération de chaîne renvoie un symbole de l'onglet chaîne ( '\ t') dans l'espace après.

Exemples

L'exemple suivant montre un exemple de expandtabs () méthode:

#!/usr/bin/python3

str = "this is\tstring example....wow!!!"

print ("原始字符串: " + str)
print ("替换 \\t 符号: " +  str.expandtabs())
print ("使用16个空格替换 \\t 符号: " +  str.expandtabs(16))

Des exemples des résultats de sortie ci-dessus sont les suivantes:

原始字符串: this is     string example....wow!!!
替换 \t 符号: this is string example....wow!!!
使用16个空格替换 \t 符号: this is         string example....wow!!!

string python3 string python3