“Python offen” Code-Antworten

Python -Datei offen

#there are many modes you can open files in. r means read.
file = open('C:\Users\yourname\files\file.txt','r')
text = file.read()

#you can write a string to it, too!
file = open('C:\Users\yourname\files\file.txt','w')
file.write('This is a typical string')

#don't forget to close it afterwards!
file.close()
Dr. Hippo

Python offen

with open("filename.txt", "r") as file:
  	print(file.read())
    
file.close()
Chinedu Francis Ozurumba

Ähnliche Antworten wie “Python offen”

Fragen ähnlich wie “Python offen”

Weitere verwandte Antworten zu “Python offen” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen