我正在尝试从Python的一个输入中获取三个必需的输入和一个第四个可选的输入的规范。
a, b, c, d = input("Please enter the number of the figure you would like and the x y coordinated in that order and a colour if you choose.").split()
我想d
使用默认值设置是可选的,但我真的很努力。
# get input
inp = input("Please enter the number of the figure you would like and the x y coordinated in that order and a colour if you choose.").split()
# check how many parameters are passed
if len(input) == 3:
# value for d is not passed
a, b, c = inp
d = default_value
else:
# value for d is passed
a, b, c, d = inp
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句