python模为什么14%5与(14)%5不同

2024-06-02 05:12:05 发布

您现在位置:Python中文网/ 问答频道 /正文

有人知道为什么下面的代码在Python中没有相同的结果吗? 为什么我需要括号才能得到正确的结果

#example 1
print 1-4 %5
outcome: -3

#example 2
print (1-4)%5
outcome: 2

Tags: 代码example括号printoutcome