Curso-lenguaje-python/python-total/dia_03/04_string.py
Manuel Vergara f4e9797c4b Restructure content and add notes from HolaMundo
Signed-off-by: Manuel Vergara <manuel@vergaracarmona.es>
2023-05-20 09:36:26 +02:00

56 lines
942 B
Python

# 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"]))