无码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看這套就的評論 (共 條)

分享到微博請遵守國家法律
赤峰市| 武川县| 义乌市| 根河市| 白沙| 兴义市| 道孚县| 雷山县| 河津市| 佳木斯市| 娄烦县| 阿坝县| 昌乐县| 昆明市| 天津市| 枣阳市| 蒙自县| 哈密市| 宁远县| 叶城县| 涟水县| 宁强县| 南丰县| 新乡县| 旬阳县| 保山市| 克东县| 宜兰县| 黔西县| 宜章县| 同德县| 通榆县| 壤塘县| 云阳县| 海宁市| 天祝| 诏安县| 隆尧县| 永宁县| 伊金霍洛旗| 临澧县|