Python乘法,变量在乘号前与后的结果差异

来源:互联网 发布:淘宝冻结资金在哪里看 编辑:程序博客网 时间:2024/06/10 03:09
1、如下的代码中
i = int(input ("Give me a number you think now,I'll show the multiplication table for the number:"))print ("Here's your table:")for j in range(1,10):           print (j,"*",i,"=",i*j)
输出的结果为:


当把变量 j 放在 i 前时:
i = int(input ("Give me a number you think now,I'll show the multiplication table for the number:"))print ("Here's your table:")for j in range(1,10):           print (j,"*",i,"=",j*i)
才能得到正确数据:


为什么呢?
百度了一下,发现 python中* 乘 表示 两个数相乘 或是返回一个被重复若干次的字符串 
但没什么具体信息,待我回家问完脑公,再解释2017/7/17
2017/7/18 脑公说,这是python中的一种规定,变量放在前即为倍数,变量放在后面即为多个该数字叠加
原创粉丝点击