Python 3.0 以éã§ã¯ãé¢æ°ãå®ç¾©ããã¨ãã«ããã¼ã¯ã¼ãå°ç¨å¼æ° ãæå®ã§ããããã«ãªãã¾ããã def func(a, b, *, c=1, d=2): return a+b+c+d ãããªã®ã§ãããå¼æ°ã®ãªã¹ãã« * ãããé¢æ°ãå¼ã³åºãã¨ãã* ã®å¾ãã«ããå¼æ°ã®å¤ã¯ãããªãããã¼ã¯ã¼ãå¼æ°ã¨ãã¦æå®ããªããã°ããã¾ããã âã®é¢æ°ã ã¨ãå¼æ° c ã¯ãã¼ã¯ã¼ãå¼æ°ã§æå®ããã°ã¡ããã¨åãã¾ãã >>> func(1, 2, c=10) 15 ãããããã¼ã¯ã¼ããªãã§å¼ã³åºãã¨ã¨ã©ã¼ã«ãªãã¾ãã >>> func(1, 2, 10) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: func() takes 2 positional arguments but 3
{{#tags}}- {{label}}
{{/tags}}