|
发表于 2020-6-22 23:46:37
|
显示全部楼层
本帖最后由 _荟桐_ 于 2020-6-22 23:49 编辑
能凑乎用一用,可以加剪乘 真除,地板除,求余,平方
前提是把数字用intt实例化,比较麻烦
- class intt(int):
- def __add__(self,other):
- return str(self) + "+" + str(other)
- def __sub__(self,other):
- return str(self) + "-" + str(other)
- def __mul__(self,other):
- return str(self) + "*" + str(other)
- def __truediv__(self,other):
- return str(self) + "/" + str(other)
- def __floordiv__(self,other):
- return str(self) + "//" + str(other)
- def __mod__(self,other):
- return str(self) + "%" + str(other)
- def __pow__(self,other):
- return str(self) + "**" + str(other)
- # 把要打印的东西intt(num)
- # 然后进行操作
- a,b,c = intt(1),intt(2),intt(3)
- print(a + b)
- print(a % b)
复制代码
改成
a = intt(random.randint(1,20)) |
|