Skip to content

Commit 56ad9d3

Browse files
Yusuf, MuhammedYusuf, Muhammed
authored andcommitted
Added the Programs for files and exceptions
1 parent cd895af commit 56ad9d3

4 files changed

Lines changed: 21 additions & 0 deletions

File tree

files/WriteJson.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
data = {}
2+
data["tom"] = {
3+
"phone":456789,
4+
"name":"tom",
5+
"address":"1210 sjtn"
6+
}
7+
data["bob"] = {
8+
"phone":98765,
9+
"name":"bob",
10+
"address":"1000 brss"
11+
}
12+
print(data)
13+
import json
14+
s = json.dumps(data)
15+
print(s)
16+
with open("data.json", "w") as f:
17+
f.write(s)

files/__init__.py

Whitespace-only changes.

files/data.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"tom": {"phone": 456789, "name": "tom", "address": "1210 sjtn"}, "bob": {"phone": 98765, "name": "bob", "address": "1000 brss"}}

files/data.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
wow i can write now - overwrite now
2+
wow i can append now
3+
I'm new line

0 commit comments

Comments
 (0)