Python open() Funzione
Esempio
Apri un file e stampa il contenuto:
f = open("demofile.txt", "r")
print(f.read())
Definizione e utilizzo
La open()
funzione apre un file e lo restituisce come oggetto file.
Maggiori informazioni sulla gestione dei file nei nostri capitoli sulla gestione dei file .
Sintassi
open(file,
mode)
Valori dei parametri
Parameter | Description |
---|---|
file | The path and name of the file |
mode | A string, define which mode you want to open the file in:
In addition you can specify if the file should be handled as binary or text mode
|
Pagine correlate
Scopri come aprire i file nel nostro Tutorial di lettura dei file
Scopri come scrivere/creare file nel nostro tutorial di scrittura/creazione di file
Scopri come eliminare i file nel nostro tutorial sull'eliminazione dei file