250x250
Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- word2vec
- 파이썬
- 이력서
- 네이버뉴스
- java
- tomoto
- (깃)git bash
- 토픽추출
- 코사인 유사도
- 게시판 만들기
- Gmarket
- 방식으로 텍스트
- oracle
- 과학백과사전
- Python
- test
- pytorch
- spring MVC(모델2)방식
- Topics
- 幼稚园杀手(유치원킬러)
- 지마켓
- 크롤링
- mysql
- RESFUL
- db
- 자바
- Websocket
- lda
- jsp 파일 설정
- r
Archives
- Today
- Total
무회blog
python: 파이썬 python Basic_Class1 본문
# # mod1.py
# data = """def add(a, b):
# return a + b
# def sub(a, b):
# return a-b
# """
# with open("mod1.py", "w") as f:
# f.write(data)
# class PlusMinuss:
# def add(a, b):
# return a + b
# def sub(a, b):
# return a-b
# print(type(PlusMinuss))
# pp = PlusMinuss.add(1,6)
# bb = PlusMinuss.sub(5,2)
# print(type(pp))
# print(type(bb))
# print(pp)
# print(bb)
# import mod1 as gg
# print(gg.add(8,2))
# gg.sub(100,30)
# 파이썬 + - * / 연산을 할수 있는 클래스
class FourCal:
def __init__(self, first, second):
self.first = first
self.second = second
# def setdata(self,first,second):
# self.first = first
# self.second = second
def add(self):
result = self.first + self.second
return result
def mul(self):
result = self.first * self.second
return result
def sub(self):
result = self.first - self.second
return result
def div(self):
result = self.first / self.second
return result
a = FourCal(5,2)
# a.setdata(8,2)
# print(a.first) # a 객체에 first 변수가 추가됨
# print(id(a.first)) # id 내장함수가 저장됨
# b = FourCal()
# b.setdata(7,3)
# print(b.first)
# print(id(b.first))
print(a.add())
print(a.mul())
print(a.sub())
print(a.div())
print(a.add() + a.mul())
class MoreFourCal(FourCal): #FourCal 클래스를 상속하는 MoreFourCal 클래스
def pow(self):
result = self.first ** self.second
return result
a = MoreFourCal(4, 2)
print(a.add()) #상속받은 FourCal 클래스의 기능을 모두 사용할 수 있음을 확인할 수 있다.
print(a.pow()) # a의 b제곱(ab)을 계산하는 MoreFourCal 클래스
import pandas as pd
dds = pd.read_excel('0507_데이터컷트중.xlsx' ,name='Sheet00')
dir([1,2,3])
'Python' 카테고리의 다른 글
DB: 200526-pyDB-001.002, DB연동 및 데이터 불러오기 (0) | 2020.05.25 |
---|---|
python:파이썬에서 DB 연결하기 - 참고자료 (2) | 2020.05.24 |
python: 20200520-ver06_Premium_python # 20200520-Gmarket-댓글수 엑셀 성공함 (0) | 2020.05.20 |
python: DaiMa_python, 파이썬-200514 (0) | 2020.05.14 |
win10 EKL 셋팅방법 (0) | 2020.05.11 |
Comments