0Pricing
NLP Academy · Lezione

Stringhe, caratteri e codifiche

Come il testo viene memorizzato come byte e Unicode

Stringhe, caratteri e codifiche è una lezione NLP Academy gratuita su CoddyKit. Questa è la lezione 1 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento NLP Academy, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso NLP Academy include 4 lezioni in totale.

Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.

Text Is Made of Characters

Every piece of text you process is a string: an ordered run of characters like letters, digits, spaces, and symbols. 🔤

Strings in Python

In Python a string is wrapped in quotes. You can store a whole sentence in a single variable and work with it as one value.

text = "NLP turns text into insight"
print(type(text))  # <class 'str'>

Each Character Has a Position

A string is indexed, so each character sits at a numbered position starting from zero. That lets you reach any single letter.

word = "data"
print(word[0])  # d
print(word[3])  # a

Computers Store Numbers

A computer cannot store the letter A directly. It stores a number, and an encoding is the agreed map between characters and those numbers.

ASCII Came First

ASCII mapped 128 basic English characters to numbers. It worked for plain English but had no room for accents or other alphabets.

Unicode Covers Everything

Unicode gives every character a unique code point, from English letters to Chinese script and emoji. Modern Python strings are Unicode.

Code Points in Python

The ord function shows a character's Unicode number, and chr turns a number back into its character.

print(ord('A'))   # 65
print(chr(233))   # é

Encoding Turns Text Into Bytes

To save or send text, Python turns it into bytes using a scheme like UTF-8. Bytes are what files and networks actually carry.

data = "café".encode("utf-8")
print(data)  # b'caf\xc3\xa9'

UTF-8 Is the Default Choice

UTF-8 stores common characters in one byte and rarer ones in more. It is compact, universal, and the standard for almost all text today.

Decoding Bytes Back to Text

Reading raw bytes means decoding them with the same scheme used to encode. The wrong scheme produces garbled or broken characters.

raw = b'caf\xc3\xa9'
print(raw.decode("utf-8"))  # café

Encoding Mistakes Cause Mojibake

Decoding with the wrong encoding gives mojibake, that jumble of odd symbols. Always know and match your encoding to avoid it.

Quick Check

Let us check the difference between two key text standards.

Recap: Text as Encoded Strings

You saw that text is a string of characters, mapped to numbers by Unicode and stored as UTF-8 bytes. Match encodings and your text stays clean. ✅

Domande Frequenti

La lezione «Stringhe, caratteri e codifiche» è gratuita?

Sì — il testo completo di «Stringhe, caratteri e codifiche» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso NLP Academy, passa a CoddyKit PRO. Il corso NLP Academy include 4 lezioni in totale.

Cosa imparerò in «Stringhe, caratteri e codifiche»?

Come il testo viene memorizzato come byte e Unicode Eserciti NLP Academy con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.

Ho bisogno di esperienza per iniziare NLP Academy?

Non è richiesta alcuna esperienza precedente. NLP Academy su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 1 di 4.

Quanto tempo richiede la lezione «Stringhe, caratteri e codifiche»?

La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.

Posso scrivere ed eseguire codice in questa lezione NLP Academy?

Sì. Ogni lezione NLP Academy include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.

Tutte le lezioni di questo corso

  1. Stringhe, caratteri e codifiche
  2. Leggere file di testo in Python
  3. Contare parole e caratteri
  4. Creare la prima tabella delle frequenze delle parole
← Torna a NLP Academy