Python oop() Funksie
Voorbeeld
Maak 'n lêer oop en druk die inhoud uit:
f = open("demofile.txt", "r")
print(f.read())
Definisie en gebruik
Die open()
funksie maak 'n lêer oop en gee dit terug as 'n lêervoorwerp.
Lees meer oor lêerhantering in ons hoofstukke oor lêerhantering .
Sintaksis
open(file,
mode)
Parameterwaardes
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
|
Verwante bladsye
Leer hoe om lêers oop te maak in ons Lees lêers-tutoriaal
Leer hoe om lêers te skryf/skep in ons Skryf/skep lêers-tutoriaal
Leer hoe om lêers uit te vee in ons Vee lêers-tutoriaal