Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Ahmad Dzikrul Fikri
1806196806-DDP1
Commits
e7c74f67
Commit
e7c74f67
authored
Apr 24, 2020
by
Ahmad Dzikrul Fikri
Browse files
Tugas Pemrograman 9 - Soal 2
parent
1443e4b7
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
TP9_
1
_1806196806.py
→
TP9_
2
_1806196806.py
View file @
e7c74f67
def
simpan_db
():
import
time
def
simpan_file
():
try
:
import
kvdb
result_f
=
open
(
"input_order2.txt"
)
result_f
=
open
(
"pembeli.txt"
)
data_baru
=
open
(
'TP9_2_1806196806.txt'
,
'w'
)
for
line
in
result_f
:
line
=
line
.
replace
(
'
\n
'
,
''
)
name
,
jumlah
=
line
.
split
()
kvdb
.
db_set
(
'UhHzASg8tRdxHtYqiQxrQ3'
,
name
,
jumlah
)
result_f
.
close
()
s
=
{}
line
=
line
.
replace
(
'/n'
,
''
)
(
id_pelanggan
,
s
[
'nama_depan'
],
s
[
'nama_belakang'
],
s
[
'tempat_tinggal'
],
s
[
'jumlah_pembelian'
],
s
[
'level_keanggotaan'
])
=
line
.
split
()
for
keys
in
s
:
data_baru
.
write
(
'pembeli:'
+
id_pelanggan
+
':'
+
keys
+
'='
+
s
[
keys
]
+
'
\n
'
)
data_baru
.
close
()
except
TypeError
:
print
(
'input ke dalam file harus berupa string'
)
except
FileNotFoundError
:
print
(
'
\n
File tidak ditemukan'
)
print
(
'Pastikan file pembeli.txt berada dalam folder yang sama dengan script ini'
)
print
(
'Pastikan juga terminal anda terhubung dengan folder ini
\n
'
)
print
(
'keluar dari program'
)
except
:
print
(
'koneksi internet hilang'
)
simpan_db
()
\ No newline at end of file
simpan_file
()
\ No newline at end of file
TP9_2_1806196806.txt
0 → 100644
View file @
e7c74f67
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment