From 6388e75d13c73af2ac069152fdbd9df7504f84e4 Mon Sep 17 00:00:00 2001 From: Cp0204 Date: Tue, 11 Jun 2024 20:59:55 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20=E5=B0=9D=E8=AF=95=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E7=AE=80=E5=8C=96=E4=BF=A1=E6=81=AF=E5=8C=B9=E9=85=8D?= =?UTF-8?q?=20#2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- telecom_class.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/telecom_class.py b/telecom_class.py index 5758f2e..ef3f8db 100644 --- a/telecom_class.py +++ b/telecom_class.py @@ -200,24 +200,24 @@ def to_summary(self, data, phonenum=""): return {} phonenum = phonenum or self.phonenum # 总流量 - flow_use = int(data["flowInfo"]["totalAmount"]["used"]) - flow_balance = int(data["flowInfo"]["totalAmount"]["balance"]) + flow_use = int(data["flowInfo"]["totalAmount"]["used"] or 0) + flow_balance = int(data["flowInfo"]["totalAmount"]["balance"] or 0) flow_total = flow_use + flow_balance # 通用流量 - common_use = int(data["flowInfo"]["commonFlow"]["used"]) - common_balance = int(data["flowInfo"]["commonFlow"]["balance"]) + common_use = int(data["flowInfo"]["commonFlow"]["used"] or 0) + common_balance = int(data["flowInfo"]["commonFlow"]["balance"] or 0) common_total = common_use + common_balance # 专用流量 - special_use = int(data["flowInfo"]["specialAmount"]["used"]) - special_balance = int(data["flowInfo"]["specialAmount"]["balance"]) + special_use = int(data["flowInfo"]["specialAmount"]["used"] or 0) + special_balance = int(data["flowInfo"]["specialAmount"]["balance"] or 0) special_total = special_use + special_balance # 语音通话 - voice_usage = int(data["voiceInfo"]["voiceDataInfo"]["used"]) - voice_balance = int(data["voiceInfo"]["voiceDataInfo"]["balance"]) - voice_total = int(data["voiceInfo"]["voiceDataInfo"]["total"]) + voice_usage = int(data["voiceInfo"]["voiceDataInfo"]["used"] or 0) + voice_balance = int(data["voiceInfo"]["voiceDataInfo"]["balance"] or 0) + voice_total = int(data["voiceInfo"]["voiceDataInfo"]["total"] or 0) # 余额 balance = int( - float(data["balanceInfo"]["indexBalanceDataInfo"]["balance"]) * 100 + float(data["balanceInfo"]["indexBalanceDataInfo"]["balance"] or 0) * 100 ) # 流量包列表 flowItems = []