패키지 준비File - Settings - Project - Project Interpreter - + 모양 클릭 후 - cx-Oracle 검색 - 설치 cmd창으로 설치cmd 실행 - pip install cx-Oracle Oracle SQL Developer -> 접속 -> + 표시 클릭 -> 정보 확인 파일 생성 """oracle_config.pyOracle 데이터베이스 서버에 접속(로그인)하기 위해 필요한 정보들을 정의""" # 사용자 이름 user = 'scott' # 비밀번호 pwd = 'tiger' # 데이터베이스 서버 주소: DSN(Data Source Name) dsn = 'localhost:1521/orcl' >>Oracle 데이터베이스 서버에서 select 구문 실행, 결과 확인현재 ..
python
window -> cmdC:\Users\user>pip listPackage Version------------------ -------attrs 19.3.0backcall 0.1.0bleach 3.1.0colorama 0.4.1cycler 0.10.0decorator 4.4.1defusedxml 0.6.0entrypoints 0.3importlib-metadata 0.23ipykernel 5.1.3ipython 7.9.0ipython-genutils 0.2.0ipywidgets 7.5.1jedi 0.15.1Jinja2 2.10.3jsonschema 3.1.1jupyter 1.0.0jupyter-client 5.3.4jupyter-console 6.0.0jupyter-core 4.6.1kiwisolver..
file open 모드(mode) r: read, 읽기 모드, 읽기 모드는 파일이 없으면 FileNotFoundError 가 발생한다. w: write, 쓰기 모드, 쓰기 모드는 파일이 없으면, 새로운 파일을 생성함. 파일이 있으면 기존 파일을 열어줌. 단, 기존 파일의 내용이 삭제됨. 덮어쓰기(overwhirite) a: append, 추가 모드 추가 모드는 파일이 없으면, 새로운 파일을 생성함. 파일이 있으면, 기존 파일의 가장 마지막에 file pointer가 위치함. 새로운 내용은 파일 끝에 추가(append) """file.readline() 사용해서 csv 파일 읽기""" import os def my_csv_reader(fn: str, header=True, encoding='utf-8') ..
"""파일을 다루는 데 다음 순서를 준수해야 한다.1) open file2) read/write file3) close file""" # 파일 열기 'w' 는 write 모드 f = open('test.txt', 'w') # 파일에 텍스트를 씀 for i in range(1, 11): f.write(f'{i}번째 줄 ... \n') # 파일 닫기 f.close() # 인코딩 오류 발생시 File - Setting - File Encodings -에서 다음 항목을 UTF-8로 변경한다. # with 구문: 리소스를 사용한 후 close() 메소드를 자동으로 호출 # with ... as 변수: 실행문 with open('test2.txt', mode = 'w', encoding= 'utf-8') as f:..