5.4 - Args, Keywords Args and Defaults

来源:互联网 发布:淘宝哪些图片不能盗用 编辑:程序博客网 时间:2024/05/29 19:12

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 argumentscreate_sphere(sz = 10, tx = 0, ty = 0, tz = 0)






0 0