我翻出了 8 年前的代码…… #! python3 #coding: utf-8 import math, random class RedPacket: __remainSize = 0 __remainMoney = 0 def __init__(self, size, money): self.__remainSize = int(size) self.__remainMoney = int(money * 100) def is_empty(self): return self.__remainSize = 1 else 1 self.__remainSize -= 1 self.__remainMoney -= money return money / 100
似乎开头的空格会被删掉,于是我把两个空格换成了全角空格: #! python3 #coding: utf-8 import math, random class RedPacket: __remainSize = 0 __remainMoney = 0 def __init__(self, size, money): self.__remainSize = int(size) self.__remainMoney = int(money * 100) def is_empty(self): return self.__remainSize = 1 else 1 self.__remainSize -= 1 self.__remainMoney -= money return money / 100