Curso-lenguaje-python/python-total/dia_03/04_string.py

56 lines
942 B
Python
Raw Permalink Normal View History

2023-04-12 21:53:51 +02:00
# Métodos de strings
## Métodos de análisis
print("Hola mundo".count("Hola"))
print("Hola mundo".find("world"))
print("C:/python36/python.exe".rfind("/"))
print("Hola mundo".startswith("Hola"))
print("abc123".isdigit())
print("1234".isnumeric())
print("1234".isdecimal())
print("abc123".isalnum())
print("abc123".isalpha())
print("abcdef".islower())
print("ABCDEF".isupper())
print("Hola mundo".isspace())
print("hola mundo".capitalize())
print("Hola mundo".encode("utf-8"))
print("Hola mundo".replace("mundo", "world"))
print("Hola Mundo!".lower())
print("Hola Mundo!".upper())
print("Hola Mundo!".swapcase())
print(" Hola mundo! ".strip())
print("Hola".center(10, "*"))
print("Hola mundo!\nHello world!".split())
print("Hola mundo!\nHello world!".splitlines())
print("Hola mundo. Hello world!".partition(" "))
print("Hola mundo. Hello world!".rpartition(" "))
print(", ".join(["C", "C++", "Python", "Java"]))