Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Microsoft Windows [Versión 10.0.19042.1348]
- (c) Microsoft Corporation. Todos los derechos reservados.
- C:\Users\Usuario>python
- Python 3.10.0 (tags/v3.10.0:b494f59, Oct 4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)] on win32
- Type "help", "copyright", "credits" or "license" for more information.
- >>> s = "Hola a todos"
- >>> s[0]
- 'H'
- >>> s[0] = "h"
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- TypeError: 'str' object does not support item assignment
- >>> s[:]
- 'Hola a todos'
- >>> s[1:]
- 'ola a todos'
- >>> s[1:-1]
- 'ola a todo'
- >>> s[1:5]
- 'ola '
- >>> lista = [1,2,3,4,5,6,7,8,9,10]
- >>> lista[::2]
- [1, 3, 5, 7, 9]
- >>> lista[1::2]
- [2, 4, 6, 8, 10]
- >>> lista[2::3]
- [3, 6, 9]
- >>> lista[2:-1:3]
- [3, 6, 9]
- >>> s
- 'Hola a todos'
- >>> s[1:-1]
- 'ola a todo'
- >>> s[1:-1:2]
- 'oaatd'
- >>> s.startswith("H")
- True
- >>> s
- 'Hola a todos'
- >>> s.startswith("Hol")
- True
- >>> s.endswith("Hol")
- False
- >>> s.endswith("dos")
- True
- >>> s.endswith("todos")
- True
- >>> "a to" in s
- True
- >>> fila = "\tHola a todos \n"
- >>> fila
- '\tHola a todos \n'
- >>> print(fila)
- Hola a todos
- >>> fila.strip()
- 'Hola a todos'
- >>> fila = " Hola a todos "
- >>> fila.strip()
- 'Hola a todos'
- >>> fila = "\tHola a todos \n"
- >>> fila.rstrip()
- '\tHola a todos'
- >>> fila.lstrip()
- 'Hola a todos \n'
- >>> s
- 'Hola a todos'
- >>> s.find("a")
- 3
- >>> s.index("a")
- 3
- >>> s.find("x")
- -1
- >>> s.index("x")
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- ValueError: substring not found
- >>> s.find("la")
- 2
- >>> s.find("a")
- 3
- >>> s.rfind("a")
- 5
- >>> s.rindex("a")
- 5
- >>> s.replace("Hola","Chau")
- 'Chau a todos'
- >>> s
- 'Hola a todos'
- >>> s = s.replace("Hola","Chau")
- >>> s
- 'Chau a todos'
- >>> s.replace("o","x")
- 'Chau a txdxs'
- >>> s.replace(" ","")
- 'Chauatodos'
- >>> s.replace("a","")
- 'Chu todos'
- >>> s
- 'Chau a todos'
- >>> s.lower()
- 'chau a todos'
- >>> s.upper()
- 'CHAU A TODOS'
- >>> s.swapcase()
- 'cHAU A TODOS'
- >>> s.casefold()
- 'chau a todos'
- >>> correo = "tatuss@ciudad.com.ar"
- >>> correo.split("@")
- ['tatuss', 'ciudad.com.ar']
- >>> nombre, server = correo.split("@")
- >>> nombre
- 'tatuss'
- >>> server
- 'ciudad.com.ar'
- >>> nombres = "Juan,Ale,Tito,Ana,Lucio"
- >>> nombres = nombres.split(",")
- >>> nombres
- ['Juan', 'Ale', 'Tito', 'Ana', 'Lucio']
- >>> lista = "root 1 2.5 1.0 /usr/bin/firefox"
- >>> usuario, pid, cpu, mem, proceso = lista.split(" ")
- >>> usuario
- 'root'
- >>> pid
- '1'
- >>> cpu
- '2.5'
- >>> mem
- '1.0'
- >>> proceso
- '/usr/bin/firefox'
- >>> correo.split("@")
- ['tatuss', 'ciudad.com.ar']
- >>> correo.partition("@")
- ('tatuss', '@', 'ciudad.com.ar')
- >>> "root 1 2.5 1.0 /usr/bin/firefox".split(" ")
- ['root', '1', '2.5', '1.0', '/usr/bin/firefox']
- >>> "root 1 2.5 1.0 /usr/bin/firefox".partition(" ")
- ('root', ' ', '1 2.5 1.0 /usr/bin/firefox')
- >>> "root 1 2.5 1.0 /usr/bin/firefox".rpartition(" ")
- ('root 1 2.5 1.0', ' ', '/usr/bin/firefox')
- >>> "root 1 2.5 1.0 /usr/bin/firefox".rpartition(" ")[-1]
- '/usr/bin/firefox'
- >>> "root 1 2.5 1.0 /usr/bin/firefox".partition(" ")[0]
- 'root'
- >>> usuario, pid, cpu, mem, proceso = lista.split(" ")
- >>> usuario
- 'root'
- >>> " ".join([usuario,pid,cpu,mem,proceso])
- 'root 1 2.5 1.0 /usr/bin/firefox'
- >>> nombre = "juan"
- >>> server = "gmail.com"
- >>> email = "@".join([nombre,server])
- >>> email
- 'juan@gmail.com'
- >>> nombres = ["juan","tito","ana"]
- >>> server
- 'gmail.com'
- >>> emails = []
- >>> for nombe in nombres:
- ... for nombe in nombres:
- KeyboardInterrupt
- >>> for nombre in nombres:
- ... emails.append("@".join([nombre,server]))
- ...
- >>> emails
- ['juan@gmail.com', 'tito@gmail.com', 'ana@gmail.com']
- >>> "34jkk!".isnumeric()
- False
- >>> "34jkk!".isascii()
- True
- >>> "34jkk!".isdigit()
- False
- >>> "34jkk!".alnum()
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- AttributeError: 'str' object has no attribute 'alnum'. Did you mean: 'isalnum'?
- >>> "34jkk!".isalnum()
- False
- >>> "34jkk!".isalpha()
- False
- >>> "234d".isdigit()
- False
- >>> "234d".isnumeric()
- False
- >>> "234d".isdecimal()
- False
- >>> "234.23".isdecimal()
- False
- >>> "234.23".isdigit()
- False
- >>> "234.23".isnumeric()
- False
- >>> "{:.2f}".format(23.58556)
- '23.59'
- >>> "{:.2f}".format(1,233,230.58556)
- '1.00'
- >>> "{:^10}".format(nombre)
- ' ana '
- >>> "{:<10}".format(nombre)
- 'ana '
- >>> "{:>10}".format(nombre)
- ' ana'
- >>> "{:e}".format(1254648648987498789789)
- '1.254649e+21'
- >>> "{:E}".format(1254648648987498789789)
- '1.254649E+21'
- >>>
- >>> s = "\t\nHola"
- >>> print(s)
- Hola
- >>> s = "\t\nHola "
- >>> print(s)
- Hola
- >>> print(repr(s))
- '\t\nHola '
Add Comment
Please, Sign In to add comment