CKTIS / Python
ascii()
Restituisce una rappresentazione come repr con escape per i caratteri non ASCII.
Versione: Python 3.14; repository image, production runtime not attested
Sintassi
ascii(object, /)Restituisce una rappresentazione come repr con escape per i caratteri non ASCII.
La rappresentazione di café conserva le virgolette e sostituisce é con una sequenza con barra inversa.
L’originale mantiene quattro punti di codice e non viene convertito in byte.
text = "café"
assert ascii(text) == "'caf" + chr(92) + "xe9'"
assert len(text) == 4 and text.endswith("é")
Esempi
text = "café"
print(ascii(text))
print(len(text))
Risultato
'caf\xe9' 4
L’originale mantiene quattro punti di codice e non viene convertito in byte.