Python % 的优先级

* 字符串格式化时我们可能这样写 ``` v = 3 "%s" % v*5 ``` 结果是多少呢? * 这要看%的优先级,显然这里的%是格式符,不是取余 * 查到官方手册 * 注意里面对于***优先级和结合性***的描述 ![优先级](https://upload-images.jianshu.io/upload_images/3399573-4e1bc416f35ab92a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) ![优先级](https://upload-images.jianshu.io/upload_images/3399573-bea0d5fc58314bd8.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) * 有了这个的描述,可以得到 * %和*相同优先级 * 从左到右结合 * 所以,结果为 ``` 33333 ``` 而不是 ``` 15 ```

你可能感兴趣的:(Python % 的优先级)