Python中文
首页
教程
问答
标签
搜索
登录
注册
Python中的操作模与顺序
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>在Zed Shaw的<a href="http://learnpythonthehardway.org" rel="nofollow">Learn Python the Hard Way</a>(第15-16页)中,他有一个示例练习</p> <pre><code> 100 - 25 * 3 % 4 </code></pre> <p>结果是97(试试!)</p> <p>我看不出能做到这一点的操作顺序。。</p> <p>100-25=75<br/> 3%4=0<br/> 或(100-25*3)=225%4=???但无论如何我不认为97。。。</p> <p>类似的例子是<code>3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6</code>,它产生7</p> <p>手术按什么顺序进行?</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>乘法>;>;mod>;>;减法</p> <pre><code>In [3]: 25 * 3 Out[3]: 75 In [4]: 75 % 4 Out[4]: 3 In [5]: 100 - 3 Out[5]: 97 </code></pre> <p>乘法和模运算符具有相同的优先级,因此在本例中从左到右求值。</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
python语法错误(如果不在Z中,则在X中表示s)
7 回答
Python语法错误(无效)概率
3 回答
python语法错误*带有可选参数的args
6 回答
python语法错误2.5版有什么办法解决吗?
5 回答
Python语法错误2.7.4
2 回答
python语法错误30/09/2013
2 回答
Python语法错误E001
9 回答
Python语法错误not()op
5 回答
python语法错误outpu
7 回答
Python语法错误print len()
5 回答
python语法错误w3
5 回答
Python语法错误不是caugh
9 回答
python语法错误及yt-packag的使用
5 回答
python语法错误可以查出来!!瓦里亚布
5 回答
Python语法错误可能是缩进?
6 回答
Python语法错误和缩进
6 回答
Python语法错误在while循环中生成随机numb
4 回答
Python语法错误在哪里?
2 回答
python语法错误在尝试导入包时,但仅在远程运行时
8 回答
Python语法错误在电子邮件地址提取脚本中
3 回答