Mögliche Duplizieren:
python open built-in function: difference between modes a, a+, w, w+, and r+?Lese-Schreib-Modus Python
try:
f = open("file.txt", "r")
try:
string = f.read()
line = f.readline()
lines = f.readlines()
finally:
f.close()
except IOError:
pass
try:
f = open("file.txt", "w")
try:
f.write('blah') # Write a string to a file
f.writelines(lines) # Write a sequence of strings to a file
finally:
f.close()
except IOError:
pass
Hallo,
dies Modus, die ich lesen und schreiben kann Datei, aber ich möchte Datei öffnen einmal und führen Sie sowohl Lese-und Schreibvorgang in Python
[HOLY bleeping BLEEP.] Schreiben (http://docs.python.org/2/library/functions.html#open) –
http://stackoverflow.com/questions/1466000/python-open-built-in-function-difference-between-modes-aaww-and-r/30931305#30931305 – industryworker3595112