Advertisement
teslariu

try completo

Oct 25th, 2021
173
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. """
  5. def sumar(a,b):
  6.     if not isinstance(a, (float,int)) or not isinstance(b, (float,int)):
  7.         raise TypeError("Los argumentos deben ser numéricos")
  8.     return a+b
  9.    
  10.    
  11. print(sumar(2,3))
  12. print(sumar("Hola","Chau"))
  13. print(sumar((2,3),(4,5)))
  14. """
  15. try:
  16.     f = open("uno.txt","x")
  17. except FileExistsError:
  18.     f = open("uno.txt", "a")
  19. else:
  20.     print("Se creó un nuevo archivo...")  
  21. finally:
  22.     f.write("Chau\n")
  23.     f.close()
Advertisement
RAW Paste Data Copied
Advertisement