1. 首页
  2. 数据库
  3. 其它
  4. 初学Python实用技巧两则

初学Python实用技巧两则

上传者: 2020-12-31 07:23:51上传 PDF文件 37.89KB 热度 24次
本文记录了初学Python常用的两则实用技巧,分享给大家供大家参考之用。具体如下: 1.可变参数 示例代码如下: >>> def powersum(power, *args): ... '''''Return the sum of each argument raised to specified power.''' ... total = 0 ... for i in args: ... total += pow(i, power) ... return total ... >>> powersum(2, 3, 4) 25 >>> powersum(2, 10) 1
下载地址
用户评论