리퀘스트하고 받는값이 요게 딕셔너리같은데 a['soft'] 요런식으로하니까
class 'dd' object is not subscriptable 뜨는거임
그래서 찾아봤는데
1
2
3
4
5
6
7
8
9
10
11
12
|
>>> class A(object):
... def __init__(self):
... self.b = 1
... self.c = 2
... def do_nothing(self):
... pass
...
>>> a = A()
>>> a.__dict__
{'c': 2, 'b': 1}
-- https://stackoverflow.com/questions/61517/python-dictionary-from-an-objects-fields
|
cs |
요렇게 뒤에 __dict__ 해주면 딕셔너리처럼 대드라고
무ㅏ dict(a) 이런거랑은 또 다른느낌같긴한데
암튼 디게 속시원해졋음
그카고 잘쓰다가 다른거또 요렇게 바꿀라니까
이번엔 앞에 b 가 붙는거임
요것도 어떻게 떼는지 알아봣음
1
2
3
4
5
6
|
import json
a= b"{'one': 1, 'two': 2}"
json.loads(a.decode('utf-8'))
**Output:** {'one': 1, 'two': 2}
-- https://stackoverflow.com/questions/49184578/how-to-convert-bytes-type-to-dictionary
|
cs |
요렇게하면댄대서 요렇게햇슴
덕분에 만든거!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
##
import os
path = os.path.dirname(os.path.abspath(__file__))
##
import requests
url = "https://api.upbit.com/v1/market/all"
querystring = {"isDetails":"false"}
headers = {"Accept": "application/json"}
response = requests.request("GET", url, headers=headers, params=querystring)
r=response.__dict__['_content']
##
import json
j=json.loads(r.decode('utf-8'))
TXT_K = open(path+"\KrwPairListofUpbit.txt", "w",encoding='UTF8')
TXT_B = open(path+"\BtcPairListofUpbit.txt", "w",encoding='UTF8')
for x in j:
if('KRW-'in x['market']):
c=x['market']
wr=c[c.find('KRW-')+4:c.find('KRW-')+20]
TXT_K.write(wr+'\n')
if('BTC-'in x['market']):
c=x['market']
wr=c[c.find('BTC-')+4:c.find('BTC-')+20]
TXT_B.write(wr+'\n')
TXT_K.write('ListEnd')
TXT_B.write('ListEnd')
TXT_K.close()
TXT_B.close()
|
cs |
페어별 주문가능 통화 정리!
요렇게!
엑셀에 받아쓰기했던거생각하면 왜그랬나싶음