zip 파이썬에서 zip()은 내장함수로 같은 길이의 리스트를 같은 인덱스끼리 잘라서 리스트로 반환을 해주는 역할을 한다. 출처: https://horensic.tistory.com/78 [horen파이썬에서 zip()은 내장함수로 같은 길이의 리스트를 같은 인덱스끼리 잘라서 리스트로 반환을 해주는 역할을 한다. 출처: https://horensic.. python&tensorflow&pytorch 2019.07.17
tuple 내부의 값은 바꿀 수 없다. tuple 내부의 값은 바꿀 수 없다. ex) def test13(): a = (1, 2, 3) a[1] = 2 => TypeError: 'tuple' object does not support item assignment python&tensorflow&pytorch 2011.01.19
for loop def test12(): for i in range(0, 100, 15): # i는 15씩 증가 print i => 0 15 30 45 60 75 90 python&tensorflow&pytorch 2011.01.19
global variable http://stackoverflow.com/questions/423379/global-variables-in-python globvar = 0 def set_globvar_to_one(): global globvar # Needed to modify global copy of globvar globvar = 1 def print_globvar(): print globvar # No need for global declaration to read value of globvar set_globvar_to_one() print_globvar() # Prints 1 python&tensorflow&pytorch 2011.01.19
string comparison def test7(): l_str1 = 'aaaaaaaa' l_str2 = 'aaaaaaaa' if l_str1==l_str2: print 'same' => same python&tensorflow&pytorch 2011.01.18
python list length def test6(): a = [] a.append(1) a.append(2) print len(a) => 2 python&tensorflow&pytorch 2011.01.18
python list http://mwultong.blogspot.com/2006/12/python-list-array-item-insert-example.html #!/usr/bin/python # -*- coding: 949 -*- a = [ "AAA", "BBB", "CCC" ] # 맨 앞에 새 요소 추가 a.insert(0, "똠방각하") print " ".join(a) # 출력 결과: 똠방각하 AAA BBB CCC # 맨 뒤에 새 요소 추가 a.append("ZZZ") print " ".join(a) # 출력 결과: 똠방각하 AAA BBB CCC ZZZ # 맨 앞의 요소.. python&tensorflow&pytorch 2011.01.14
conversion from string to integer http://mwultong.blogspot.com/2007/01/python-int-long-float-string-to-number.html # "정수 문자열"을 정수로 만들어, 플러스 1 하기 s = "123" n = int(s) + 1 print n # 출력 결과: 124 python&tensorflow&pytorch 2011.01.10
python thread http://www.wellho.net/solutions/python-python-threads-a-first-example.html import os import re import time import sys from threading import Thread class testit(Thread): def __init__ (self,a_cnt): Thread.__init__(self) self.l_cnt = a_cnt def run(self): while 1: print self.l_cnt time.sleep(1) print time.ctime() pinglist = [] for l_cnt in range(0,10): current = testit(l_cnt) pinglist.append(curren.. python&tensorflow&pytorch 2011.01.10