💻Programming/Python4 [Python/파이썬] DB연결, CRUD(Create, Read, Update, Delete) Python과 Oracle DB연결, CRUD -- Oracle에 sample테이블 생성 CREATE TABLE "PYTHON"."SAMPLE" ( "COL01" VARCHAR2(20 BYTE) NOT NULL ENABLE, "COL02" VARCHAR2(20 BYTE), "COL03" VARCHAR2(20 BYTE) ) -- SELECT -- #Oracle DB와 연결하기 위한 모듈 설치 import cx_Oracle #Oracle DB의 python과 연결 conn = cx_Oracle.connect('python/python@localhost:1521/xe') #다음 줄로 이동 (데이터 유무 확인) cs = conn.cursor() #select문 실행 후 데이터 가져오기 rs = cs.execut.. 💻Programming/Python 2021. 3. 17. [Python/파이썬] 분기문 ( if 문 : 홀짝, 가위바위보) 1. 분기문 ( if 문 ) if 1 > 0 : print('참') else : print('거짓') #출력 결과 참 ------------------------------------------------ #90점 이상이면 수, 80점 이상이면 우, 70점 이상이면 미, 60점 이상이면 양, 그 이하면 가 if score >= 90 : print('수') elif score >= 80 : print('우') elif score >= 70 : print('미') elif score >= 60 : print('양') else : print('가') ------------------------------------------------ # 홀짝 맞추기 import random mine = input("홀/짝을.. 💻Programming/Python 2021. 3. 17. [Python/파이썬] 반복문 (for문) 1. 반복문 (for문) for i in range(5) : print('hello') #출력결과 hello hello hello hello hello ------------------------------------------------ for i in range(5): print("hello",end=" ") #출력결과 hello hello hello hello hello ------------------------------------------------ a = range(1,5) for i in a : print(a[i-1]) #a의 범위는 1부터 시작. 인덱스는 0부터 시작 => -1 해서 범위 맞춰주기 #출력결과 1 2 3 4 ------------------------------------.. 💻Programming/Python 2021. 3. 17. [Python/파이썬] print() 1. 파이썬 print() print("hello world") a = 5 b = 5 print(a+b) #10 print(str(a)+str(b)) #55 💻Programming/Python 2021. 3. 17. 이전 1 다음