kopia lustrzana https://github.com/micropython/micropython
35 wiersze
461 B
Python
35 wiersze
461 B
Python
import os
|
|
|
|
if not hasattr(os, "remove"):
|
|
print("SKIP")
|
|
raise SystemExit
|
|
|
|
# cleanup in case testfile exists
|
|
try:
|
|
os.remove("testfile")
|
|
except OSError:
|
|
pass
|
|
|
|
# Should create a file
|
|
f = open("testfile", "a")
|
|
f.write("foo")
|
|
f.close()
|
|
|
|
f = open("testfile")
|
|
print(f.read())
|
|
f.close()
|
|
|
|
f = open("testfile", "a")
|
|
f.write("bar")
|
|
f.close()
|
|
|
|
f = open("testfile")
|
|
print(f.read())
|
|
f.close()
|
|
|
|
# cleanup
|
|
try:
|
|
os.remove("testfile")
|
|
except OSError:
|
|
pass
|