質問編集履歴

1

誤字などの修正

2020/11/06 06:54

投稿

byakko0915
byakko0915

スコア4

test CHANGED
File without changes
test CHANGED
@@ -16,25 +16,25 @@
16
16
 
17
17
  ```Python
18
18
 
19
- with open("coin/" + message.author.name + '.yaml') as yf:
19
+ try:
20
20
 
21
- coins = yaml.safe_load(yf)
21
+ with open("coin/" + message.author.name + '.yaml') as yf:
22
22
 
23
- try:
23
+ coins = yaml.safe_load(yf)
24
24
 
25
- coins = coins['Coins'] + random.randint(10,50)
25
+ coins = coins['Coins'] + random.randint(10,50)
26
26
 
27
- except TypeError:
27
+ except FileNotFoundError:
28
28
 
29
- coins = 1
29
+ coins = 1
30
30
 
31
- with open("coin/" + message.author.name + '.yaml', mode='w') as yf:
31
+ with open("coin/" + message.author.name + '.yaml', mode='w') as yf:
32
32
 
33
- yaml.dump({
33
+ yaml.dump({
34
34
 
35
- "Coins": coins
35
+ "Coins": coins
36
36
 
37
- }, yf, default_flow_style=False)
37
+ }, yf, default_flow_style=False)
38
38
 
39
39
  ```
40
40
 
@@ -59,5 +59,3 @@
59
59
 
60
60
 
61
61
  repl.it
62
-
63
- Python 1.3.4