最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(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看這套就的評論 (共 條)

分享到微博請遵守國家法律
关岭| 平遥县| 昌黎县| 平和县| 调兵山市| 乐陵市| 遂平县| 石屏县| 隆安县| 通江县| 长沙县| 贺州市| 冕宁县| 兖州市| 石河子市| 南投县| 深圳市| 汾阳市| 罗源县| 梅河口市| 鞍山市| 托克逊县| 城市| 东宁县| 湘阴县| 彭水| 张北县| 宁河县| 临颍县| 萝北县| 礼泉县| 都安| 隆林| 大方县| 历史| 濮阳市| 马龙县| 拜城县| 忻城县| 安平县| 策勒县|