无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

黑馬程序員python教程,8天python從入門到精通,學(xué)python看這套就

2023-06-18 19:26 作者:JayJu  | 我要投稿

P124

import json


class dataInfo:

??def __init__(self, data: str, id: str, money: str, province: str) -> None:

????self.date: str = data

????self.id: str = id

????try:

??????self.money: int = int(money)

????except Exception:

??????print("Error:Money isn't number!")

????self.province: str = province


class data:

??path: str = None

??__list:list[dataInfo] = []


??def __init__(self, path: str) -> None:

????self.path = path


??def ReadCsv(self) -> None:

????'''Csv格式的數(shù)據(jù)讀取'''

????with open(self.path, "r", encoding="utf-8") as f:

??????for x in f.readlines():

????????# 單行數(shù)據(jù)整理,去除\n

????????temp = x.strip()

????????# 數(shù)據(jù)拆分

????????temp = temp.split(",")

????????self.__list.append(dataInfo(temp[0], temp[1], temp[2], temp[3])

????????)


??def ReadJson(self) -> None:

????'''Json格式的數(shù)據(jù)讀取'''

????with open(self.path, "r", encoding="utf-8") as f:

??????for x in json.loads(f.read()):

????????self.__list.append(

??????????dataInfo(x['date'], x['order id'], x['money'], x['province'])

????????)


??def Get(self) -> list[dataInfo]:

????'''獲得數(shù)據(jù)列表'''

????return self.__list

黑馬程序員python教程,8天python從入門到精通,學(xué)python看這套就的評論 (共 條)

分享到微博請遵守國家法律
闽清县| 扎兰屯市| 安化县| 潮安县| 公安县| 海南省| 荔波县| 铁岭市| 元氏县| 嵩明县| 攀枝花市| 荣成市| 长海县| 福泉市| 南城县| 法库县| 靖宇县| 万盛区| 惠州市| 巴彦县| 千阳县| 伊宁县| 葫芦岛市| 枝江市| 龙陵县| 胶南市| 洛南县| 新闻| 荔波县| 崇明县| 定西市| 枝江市| 九寨沟县| 藁城市| 遂平县| 巩留县| 新绛县| 广平县| 广德县| 正镶白旗| 贺州市|