Open JungHulk opened 1 year ago
# -*- coding: utf-8 -*- """ Created on Tue Jan 31 18:05:11 2023 @author: seungj.jung """ import os import pandas as pd import pickle unitconv_length = pd.read_pickle('Unitconv_length.p') unitconv_area = pd.read_pickle('Unitconv_area.p') unitconv_volume = pd.read_pickle('Unitconv_volume.p') unitconv_pressure = pd.read_pickle('Unitconv_pressure.p') class unitconv: def __init__(self,selection, fromunit, tounit, value): self.type = selection # length, area, volume self.funit = fromunit # 기존 단위 self.tunit = tounit # 변경하고자 하는 단위 self.value = value # 값 def cal(self): if self.type == "length": factor = unitconv_length.loc[self.funit, self.tunit] sol = factor * self.value elif self.type =="area": factor = unitconv_area.loc[self.funit, self.tunit] sol = factor * self.value elif self.type =="volume": factor = unitconv_volume.loc[self.funit, self.tunit] sol = factor * self.value elif self.type =="pressure": factor = unitconv_pressure.loc[self.funit, self.tunit] sol = factor * self.value return sol ## a = unitconv("length","mm", "ft", 50) ## b = a.cal() ## a = unitconv("length","mm", "ft", 50).cal()