Tuttofaredigitale.it
Tutorial
HTML & CSSJavaScriptLinuxPythonSQL
Blog
Funzioni built-in
Python abs()
Python all()
Python any()
Python bin()
Python bool()
Python bytearray()
Python bytes()
Python callable()
Python chr()
Python classmethod()
Python compile()
Python complex()
Python delattr()
Python dict()
Python dir()
Python divmod()
Python enumerare()
Python eval()
Python exec()
Python filter()
Python float()
Python format()
Python frozenset()
Python getattr()
Python globals()
Python hasattr()
Python hash()
Python hex()
Python id()
Python input()
Python int()
Python isinstance()
Python issubclass()
Python iter()
Python len()
Python list()
Python locals()
Python map()
Python max()
Python memoryview()
Python min()
Python next()
Python object()
Python oct()
Python open()
Python ord()
Python pow()
Python print()
Python property()
Python range()
Python repr()
Python reversed()
Python round()
Python set()
Python setattr()
Python slice()
Python sorted()
Python staticmethod()
Python str()
Python sum()
Python super()
Python tuple()
Python type()
Python vars()
Python zip()
Python Tutorial >
Funzioni built-in

Python repr()

La funzione repr() restituisce una rappresentazione stampabile dell'oggetto dato.

La sintassi di repr() è:

repr(obj)

La funzione repr() prende un singolo parametro l'oggetto la cui rappresentazione stampabile deve essere restituita.

var = 'ciao'

print (repr(var))

Output del codice

'ciao'

Altro esempio:

class Persona:
   nome = 'Mario'

   def __repr__(self):
       return repr('Ciao ' + self.nome )

print (repr(Persona()))

Output del codice

'Ciao Mario'
NordVPN Naviga velocemente ed in tutta sicurezza

Informazioni

Canale YouTube
  • BlogContatti

Tutorial

  • HTML & CSS
  • JavaScript
  • Linux
  • Python
  • SQL

Termini & Co.

  • Privacy PolicyCookies Policy
© 2023 tuttofaredigitale.it - Cliccando sui link di Amazon una somma di denaro viene corrisposta dagli acquisti idonei.