본문 바로가기

Python

(6)
Formatting time 자주 쓰는 method라서... import datetime def format_time(): t = datetime.datetime.now() s = t.strftime('%Y-%m-%d %H:%M:%S.%f') return s[:-3] current_time = format_time()
List with * Useful tip. list1 = ["ryan", "tracy"] list2 = ["44", "42"] list3 = ["male", "female"] new_list = [list1, list2, list3] for i in zip(*new_list): print(i) Output: ('ryan', '44', 'male') ('tracy', '42', 'female')
[Python] lambda vs list comprehension 아래 두개는 동일한 표현식 결과도 같다. range(1,10)을 쓰면 [1,2,3,4,5,6,7,8,9]의 list를 반환한다. 요즘 추세는 list comprehension을 쓰는 trend. lambda를 쓰면 readability가 떨어진다고.... 1) Lambda>>> list(filter(lambda x:x%3==0, range(1,10))) [3, 6, 9] 2) list comprehension>>> [x for x in range(1,10) if x%3 == 0] [3, 6, 9]
[Python] Virtual Environment 1) 설치하기$ pip install virtualenv 2) 만들기# Python 2:$ virtualenv env # Python 3$ python3 -m venv venv (Last argument는 folder name in local) 3) 실행하기source venv/bin/activate실행하면, terminal prompt 앞에 (venv)가 보임(venv) $ 4) 중지하기(venv) $ deactivate
Xing API] Real time data subscribe 이베스트 증권에서 제공하는 Xing API로 만든 Real Time data subscribe 예제입니다.
Xing API] Connection and login Python으로 처음 만들어 본 Class이다. Coding Convention에 맞게 작성한지도 몰겠고, OnLogout 같은 delegate은 불려지지도 않고.... 내가 잘못 만든건지, COM에서 제공을 안하는 건지 감이 안온다. 그래서 빼버렸다.