Skip to content

Instantly share code, notes, and snippets.

View hyeonchan523's full-sized avatar

Hyeonchan Lee hyeonchan523

View GitHub Profile
## 기존 pattern
def check_conditions(guard_1, guard_2):
if (guard_1):
if (guard_2):
print('guard_1 & 2 are all satisfied')
return True
else:
print('guard_2 is not satisfied')
return False
else:
username = "username"
pwd = "pwd"
if (check_username(username)): #1 guard 1
if (check_pwd(username, pwd)): #2 guard 2
pass
else:
print("암호가 잘못되었습니다.")
else:
print("사용자명이 잘못되었습니다.")
# 2. Text box에 있는 데이터 불러오기
## presentation.슬라이드.텍스트 포함 셰이프.TextFrame.TextRange.Text
print('2. Text box에 있는 데이터 불러오기')
print(presentation.Slides(2).Shapes('Title 1').TextFrame.TextRange.Text)
print(presentation.Slides(2).Shapes('Rectangle 4').TextFrame.TextRange.Text)
print(presentation.Slides(2).Shapes('TextBox 6').TextFrame.TextRange.Text)
# 3. Table에 있는 데이터 불러오기
## table shape에 접근해 행과 열 번호로 데이터에 접근할 수 있다.
## Table 각각의 cell을 하나의 shape로 생각하고 TextFrame부터 Text까지 접근하면 된다.
import win32com.client
# 1. ppt file 열기
ppt = win32com.client.Dispatch('PowerPoint.Application')
ppt.Visible = True
presentation = ppt.Presentations.Open('pptx directiory')
# 2. ppt slide를 순회하며 shape에 접근
print('\nAs-is ---')
for slide in presentation.Slides: # presentation.Slides는 presentation 내에 장표들
import xlwings as xw
# 1. 엑셀 앱 실행
## 엑셀 앱을 실행한 후 작업하고자 하는 workbook을 생성한다.
## 여러 개의 파일을 다룰 때 xw.APP()를 사용하면 여러 개의 파일을 효과적으로 다룰 수 있기 때문에 편리하다.
## visible 설정을 False로 하면 엑셀 화면을 띄우지 않고 작업을 할 수 있다.
app = xw.App(visible = True) ## 엑셀 화면을 보지 않고 작업하길 원하면 visible = False로 지정하면 된다.
wb = xw.Book()
wb.sheets.add(after = wb.sheets[-1]) #맨 뒤에 하나의 시트를 추가한다.
# 라이브러리 임포트
import xlwings as xw
# 1. workbook 접근
## 열고자하는 excel file의 경로를 입력한다.
## 빈칸으로 둘 경우 빈 excel file 하나를 생성한다.
wb = xw.Book()
# 2. workbook 내 sheet 접근
## sheets['sheet 이름'] or sheets[순서]로 접근
import sys
from collections import deque
def solve():
def BFS(r, c):
nonlocal table
dr = [0,0,1,-1]
dc = [1,-1,0,0]
q = deque()
import sys
Dir = { #동 서 북 남
1:(0,1),
2:(0,-1),
3:(-1,0),
4:(1,0)
}
class dice:
def __init__(self,r, c):
import sys
def solve(R,C,L):
global white, blue, TABLE
def check(color):
for r in range(L):
for c in range(L):
cur_r, cur_c = R+r, C+c
if color != TABLE[cur_r][cur_c]:
x = int(input())
DP = [0]*(x + 1) #DP 1은 0
for idx in range(2, x+1):
if idx % 6 == 0:
DP[idx] = min(DP[idx-1],DP[idx//3], DP[idx//2]) + 1
elif idx % 3 == 0:
DP[idx] = min(DP[idx-1],DP[idx//3]) + 1
elif idx % 2 == 0:
DP[idx] = min(DP[idx-1],DP[idx//2]) + 1