关闭

5.4 - Args, Keywords Args and Defaults

194人阅读 评论(0) 收藏 举报
分类:

def create_sphere(tx, ty, tz, sx, sy, sz):
    print("translate -> ({0}, {1}, {2}) //".format(tx, ty, tz))
    print("scale -> ({0}, {1}, {2})".format(sx, sy, sz))
          
create_sphere(0, 0, 0, 1, 1, 1)      
          
def create_sphere(tx, ty, tz, sx = 1, sy = 1, sz = 1):
    print("translate -> ({0}, {1}, {2}) //".format(tx, ty, tz))
    print("scale -> ({0}, {1}, {2})".format(sx, sy, sz))
          
create_sphere(0, 0, 0)
create_sphere(0, 0, 0, sz = 10)    # if you only want to alter some default values, you can only pass the name which you want to alter

#create_sphere(sz = 10, 0, 0, 0) # error, the keyword arguments alway come after the required arguments
create_sphere(sz = 10, tx = 0, ty = 0, tz = 0)






0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:414996次
    • 积分:10077
    • 等级:
    • 排名:第1812名
    • 原创:590篇
    • 转载:90篇
    • 译文:0篇
    • 评论:96条
    最新评论