< id="tt-body-category">
본문 바로가기 메뉴 바로가기

burningrizen

프로필사진
  • 글쓰기
  • 관리
  • 태그
  • 방명록
  • RSS

burningrizen

검색하기 폼
  • 분류 전체보기 (254)
    • development (14)
      • python (5)
      • django (4)
      • git (3)
      • ubuntu (1)
      • aws (1)
    • common (3)
      • tistory (2)
      • document (0)
    • python lecture (233)
      • basic (96)
      • concurrency (11)
      • functional programming (1)
      • cleancode (1)
      • common (6)
      • algorism (31)
      • programmers (65)
      • project (22)
  • 방명록

python lecture/basic (96)
[edu] 순열, 조합

[순열] 중복 없음 import itertools nums_a = [1, 2, 3] permu_a = itertools.permutations(nums_a, 2) 중복 import itertools nums_a = [1, 2, 3] permu = itertools.product(nums_a, repeat=2) [조합] 중복 없음 import itertools nums_a = [1, 2, 3] permu = itertools.combinations(nums_a, repeat=2) 중복 import itertools nums_a = [1, 2, 3] permu = itertools.combinations_with_replacement(nums_a, repeat=2)

python lecture/basic 2018. 11. 13. 14:09
[edu] 파이썬 시작하기 - 이메일 보내기

[Naver SMTP 설정] https://mail.naver.com/option/imap [gmail smtp 설정] 아래 주소로 접속 https://support.google.com/mail/answer/7104828?hl=ko&visit_id=636765832801774601-2011122225&rd=1 POP 설정을 먼저 한다. 빨간색 되있는 곳을 체크해 준다. gmail 자체 보안 레벨 때문에 보안수준을 낮은 앱 허용으로 변경 해주어야 한다. gmail smtp 설정이 완료되었다 [텍스트 보내기] import smtplib from email.mime.text import MIMEText me = '보내는사람' to_naver = '네이버 메일' to_gmail = '지메일' contents =..

python lecture/basic 2018. 10. 31. 21:07
[edu] 파이썬 시작하기 - 엑셀 입출력

[엑셀 쓰기] from openpyxl import Workbook import datetime wb = Workbook() ws = wb.active ws['A1'] = 42 ws.append([1, 2, 3]) ws['A3'] = datetime.datetime.now() wb.save("sample.xlsx") [엑셀 읽기] from openpyxl import Workbook from openpyxl import load_workbook wb = load_workbook(filename='sample.xlsx') name_sheet = 'Sheet' if name_sheet in wb: sheet = wb[name_sheet] multiple_cells = sheet['A1':'C3'] for r..

python lecture/basic 2018. 10. 31. 20:30
[edu] 파이썬 시작하기 - 파일 입출력

[파일쓰기] with open("data.txt", "w") as f: for i in range(10): data = "{} line!\n".format(i) f.write(data) [파일읽기] with open("data.txt", "r") as f: while True: line = f.readline() if not line: break print(line) 한줄씩 읽기 with open("data.txt", "r") as f: lines = f.readlines() for line in lines: print(line) 한번에 읽기

python lecture/basic 2018. 10. 31. 19:21
[edu] closure (클로저, nonlocal)

클로저는 일반 함수와 다르게, 자신(inner function)의 영역밖에서 호출된 함수의 변수값과 레퍼런스를 복사, 저장 접근을 가능하게 한다. def sort_priority(values, group): def helper(x): if x in group: return 0, x return 1, x values.sort(key=helper) numbers = [8, 33, 1, 2, 5, 4, 7, 6] group = {2, 3, 5, 7} sort_priority(numbers, group) print(numbers) sort_priority 의 동작은 group 이라는 집합에 포함되어 있으면 오름차순에서 우선순위를 준다. 멤버십 테스트를 통과 여부에 따라 0, 1의 가중치를 두어서 두그룹으로 분류..

python lecture/basic 2018. 10. 2. 21:41
[edu] 파이썬 시작하기 - 13 (work queue)

[폰트사이즈18 고딕 진하게] workqueue 에 push 하고 pop 할때 마다 매번 다른 쓰레드로 동작 import threading import time def foo(t): i = 0 while True: print(threading.currentThread().getName(), i) i += 1 time.sleep(t) class WorkQueue: def __init__(self): self.works = list() def push(self, cb, *args, **kwargs): self.works.append((cb, args, kwargs)) def pop(self): if len(self.works): work, args, kwargs = self.works.pop(0) t = t..

python lecture/basic 2018. 9. 24. 18:34
[edu] 파이썬 시작하기 - 12 (deque)

[Deque:queue] 폰트 사이즈 12 고딕 폰트 사이즈 12 고딕 폰트 사이즈 12 고딕 폰트 사이즈 12 고딕 폰트 사이즈 12 고딕 폰트 사이즈 12 고딕from collections import deque q = deque() q.append(1) q.append(2) print(len(q)) print(q.popleft()) print(len(q)) print(q.popleft())

python lecture/basic 2018. 9. 24. 18:08
[edu] 파이썬 시작하기 - 11 (thread)

[Thread] 폰트 사이즈 12 고딕 폰트 사이즈 12 고딕 폰트 사이즈 12 고딕 폰트 사이즈 12 고딕 폰트 사이즈 12 고딕 데몬쓰레드는 메인쓰레드가 종료되면 종료된다.import threading def sum(low, high): total = 0 for i in range(low, high): total += i print("sum=" + str(total)) t = threading.Thread(target=sum, args=(1, 100)) t.daemon = True t.start()

python lecture/basic 2018. 9. 24. 18:05
[edu] 파이썬 시작하기 - 10 (decorator)

[Decorator: func] - 로그를 남길때 - 성능을 측정할 때 - 유저의 상태를 남기기 위한 redirect [performance.py] 일반 함수에 사용될 경우import time def stop_watch(func): def wrapper(*args, **kwargs): start = time.time() result = func(*args, **kwargs) print("{}: delay={}".format(func.__name__, time.time()-start)) return result return wrapper class 함수에 사용될 경우 인자 맨앞에 self 를 위치 시킨다.import time def stop_watch(func): def wrapper(self, *args..

python lecture/basic 2018. 9. 21. 16:46
[edu] 파이썬 시작하기 - 8

[모듈 임포트] 소스 코드를 작성하다 보면 하나의 파일에 모든 것을 담을 수 없다. 기능별로 모듈화 해서 여러 파일에 저장하게 된다. 여러파일에 있는 모듈들을 임포트해서 사용해보자! zoo.py 에서 정의된 함수 find() 를 사용해 보자 def find(): print("find!") 다음과 같이 함수 하나를 정의했다. 이것을 root.py 에서 호출해보자 import zoo zoo.find() zoo 는 모듈이름(파일이름) 이고 해당 모듈에 있는 함수는 module.method 이렇게 호출하면된다. 모듈에 정의된 클래스는 어떻게 접근할까? class Animal: pass zoo.py 에 클래스를 정의하고 import zoo z = zoo.Animal() 함수와 마찬가지로 접근하면 된다. 예를 들어..

python lecture/basic 2018. 8. 29. 20:08
이전 1 ··· 6 7 8 9 10 다음
이전 다음
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
  • 장고
  • virtualenv
  • 모바일 스킨 적용
  • 파이썬 독학
  • 면접정답
  • django chatbot
  • 장고 카톡 자동응답
  • 파이썬 입문
  • GIT
  • gitlab
  • chatbot
  • django
  • Tistory
  • Python
  • 모바일 테마 적용
  • pycrypto
  • 장고 플러스친구 자동응답
  • 면접답변
  • 플러스친구 자동응답
  • 이미지 비교
  • 문과 코딩
  • 문서 비교
  • admin.py
  • gitignore
  • 파이썬
  • 파이썬 프로그래밍
  • 파이썬 강좌
  • wsgi
  • PuTTYGen
  • 엑셀 비교
more
«   2025/09   »
일 월 화 수 목 금 토
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
글 보관함

Blog is powered by Tistory / Designed by Tistory

티스토리툴바