일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
- SQLSCOTT
- sql따라하기
- 파이썬
- 맷플롯립
- SQL
- 주피터노트북판다스
- 파이썬데이터분석
- 파이썬알고리즘
- 파이썬시각화
- 파이썬데이터분석주피터노트북
- SQL수업
- 수업기록
- python알고리즘
- 팀플기록
- 주피터노트북맷플롯립
- 주피터노트북데이터분석
- 파이썬차트
- 주피터노트북
- 주피터노트북그래프
- 판다스그래프
- sql연습하기
- sql연습
- matplotlib
- python수업
- 파이썬수업
- 판다스데이터분석
- 파이썬크롤링
- python데이터분석
- Python
- 데이터분석시각화
- Today
- Total
목록Python (61)
IT_developers

모듈 : 함수나 변수 또는 클래스들을 모아 놓은 파일 . 패키지 정도 모듈 사용하기 import 모듈명 import 모듈명 as 별칭 from 모듈명 import 모듈 함수(특정한 함수) from 모듈명 import 모듈 함수 as 별칭 from 모듈명 import *== import 모듈명 # sys 모듈 import sys print(sys.builtin_module_names) 파이썬이 기본으로 가지고 있는 모듈 확인 Ctrl + 마우스 오버 : 클래스를 확인 할 수 있음. # math 모듈 import math # math 안에 있는 모든 것들이 import print(dir(math)) print(math.__doc__) # ddefined by the C standard # C언어 기반 pri..

오버라이딩 : 부모클래스가 가지고 있는 메소드 재정의 class Parent: def func1(self): print("Parent func1()") def func2(self): print("Parent func2()") class Child(Parent): def func1(self): print("Child func1()") def func3(self): print("Child func2()") parent, child = Parent(), Child() parent.func1() child.func1() parent.func2() child.func2() child.func3() # Car ==> upspeed 오버라이딩 class Car: speed = 0 def up_speed(self, v..

# 클래스 변수와 인스턴스 변수 차이 class Car: """ UserInfo class Author : 홍길동 Date : 2022-05-26 Description : 클래스 작성법 """ # 클래스 변수 car_count = 0 # 인자를 받는 생성자 def __init__(self, count, color, speed) -> None: self.color = color self.speed = speed Car.car_count += count def upSpeed(self, value): self.speed += value def downSpeed(self, value): self.speed -= value # 객체 삭제 def __del__(self): Car.car_count -= 1 # 객체..

파이썬 클래스 클래스를 꼭 필요로 하진않음. 클래스를 만들어 놓으면 계속 불러서 쓸 수 있음 안할 땐 변수로 가능 클래스 사용하지 않고 학생 3명의 정보 변수 사용해서 학생 3명 입력. 변수명이 중복 불가. # 학생 1 student_name1 = "Kim" student_number_1 = 1 student_grade_1 = 1 student_detail_1 = [{"gender": "male"}, {"score1": 97}, {"score2": 88}] # 학생 2 student_name2 = "Park" student_number_2 = 2 student_grade_2 = 2 student_detail_2 = [{"gender": "female"}, {"score1": 87}, {"score2": ..

csv 파일 입출력 import csv 선언하기! csv : 클래스 # sample1.csv 읽어오기 with open("data/sample1.csv", "r") as f: # csv 행단위로 읽어옴. reader = csv.reader(f) # reader : 읽어오기 # 헤더명 제거 next(reader) # ['번호', '이름', '가입일시', '나이'] 제거 print(reader) # print(type(reader)) print(dir(reader)) for c in reader: print(c) # sample2 읽어오기 with open("data/sample2.csv", "r") as f: reader = csv.reader(f) for c in reader: print(c) # 옵션 ..

data 폴더 안에 넣기 파일 읽기 with open("data/review.txt", "r", encoding="utf-8") as f: print(f.read()) readline() : 줄 단위로 읽어오기 with open("data/review.txt", "r", encoding="utf-8") as f: print(f.readline()) with open("data/review.txt", "r", encoding="utf-8") as f: line = f.readline() while line: print(line, end=" ") line = f.readline() readlines : 파일의 내용을 리스트로 가져오기 with open("data/review.txt", "r", encodin..

화면 출력 print, 입력 input open("파일명", 모드, encoding...) : 파일을 읽거나 쓸 때 사용 with + open() : close()를 알아서 해줌 f = open("data/test1.txt", "w", encoding="utf-8") f.write("안녕하세요\n반갑습니다.") f.close() with open("data/test1.txt", "w", encoding="utf-8") as f: f.write("안녕하세요\n반갑습니다.") # 1~10까지 파일로 작성 # w : 기존에 있던 내용은 무시하고 새로 작성 f = open("data/test1.txt", "w", encoding="utf-8") for i in range(1, 11): f.write("%d\n"..

람다(Lambda) 함수 단일문으로 표현 되는 익명함수 코드 상에서 한 번만 사용되는 기능이 있을 때 굳이 함수로 만들지 않고 1회성으로 만들어서 사용 def square(x): return x**2 print(square(5)) # 람다식 변형 square = lambda x: x**2 print(type(square)) print(square(5)) def add(x, y): return x + y print(add(15, 2)) # 람다식 변형 add = lambda x, y: x + y print(add(15, 2)) 리스트 구조 # 문자의 길이가 짧은 순서대로 정렬하고 싶음 def str_len(s): return len(s) strings = ["bob", "charles", "alexande..