We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c7d19ab commit cc62e5dCopy full SHA for cc62e5d
python_csv/create_tempfile.py
@@ -0,0 +1,30 @@
1
+import os
2
+import tempfile
3
+
4
+temp = tempfile.NamedTemporaryFile(delete=False)
5
+print(temp.name)
6
7
+temp.write(b"Hello world\n")
8
+temp.seek(0)
9
+print(temp.read())
10
+temp.close()
11
+os.unlink(temp.name)
12
+print(os.path.exists(temp.name))
13
14
+with tempfile.NamedTemporaryFile(delete=False) as tp:
15
+ print(tp.name)
16
+ tp.write(b"Greetings python")
17
+ tp.seek(0)
18
+ print(tp.read())
19
+ tp.close()
20
+ os.unlink(tp.name)
21
+ print(os.path.exists(tp.name))
22
23
24
+with tempfile.NamedTemporaryFile() as temp:
25
+ print(temp.name)
26
+ temp.write(b"writing data in temporary file")
27
+ temp.seek(0)
28
+ print(temp.read())
29
+ temp.close()
30
+ print(os.path.exists(temp.name))
0 commit comments