Esta división ha sido probado por expertos para asegurar la veracidad de nuestro tutorial.
Ejemplo 1: caracteres de la tira de python
# Python3 program to demonstrate the use of # strip() method
string =" python strip method test "# prints the string without stripping print(string)# prints the string by removing leading and trailing whitespaces print(string.strip())# prints the string by removing strip print(string.strip(' strip'))
Output:
python strip method test
python strip method test
python method test
Ejemplo 2: tira en python
txt =" banana "
x = txt.strip()#x will be "banana"
Ejemplo 3: tira de pitón
# removes outside whitespace/characters' hey '.strip()# "hey"' hey '.lstrip()# "hey "' hey '.rstrip()# " hey"'_.hey__'.strip('._')# "hey"
Ejemplo 4: tira de pitón
txt =" test "
txt.strip()#Output: "test"
txt.lstrip()#Output: "test "
txt.rstrip()#Output: " test"
Ejemplo 5: .strip() python
string =' xoxo love xoxo '# Leading and trailing whitespaces are removedprint(string.strip())# All ,x,o,e characters in the left # and right of string are removedprint(string.strip(' xoe'))# Argument doesn't contain space# No characters are removed.print(string.strip('stx'))
string ='android is awesome'print(string.strip('an'))
Ejemplo 6: python input().strip()
txt =" banana "
x = txt.strip()print("of all fruits", x,"is my favorite")
txt =",,,,,rrttgg.....banana....rrr"
x = txt.strip(",.grt")print(x)
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)