SyntaxError: non-default argument follows default argument

后端 未结 3 1865
离开以前
离开以前 2020-12-07 13:05
from os import system
def a(len1,hgt=len1,til,col=0):
    system(\'mode con cols=\'+len1,\'lines=\'+hgt)
    system(\'title\',til)
    system(\'color\',col)

a(64,25         


        
3条回答
  •  余生分开走
    2020-12-07 13:20

    As the error message says, non-default argument til should not follow default argument hgt.

    Changing order of parameters (function call also be adjusted accordingly) or making hgt non-default parameter will solve your problem.

    def a(len1, hgt=len1, til, col=0):
    

    ->

    def a(len1, hgt, til, col=0):
    

    UPDATE

    Another issue that is hidden by the SyntaxError.

    os.system accepts only one string parameter.

    def a(len1, hgt, til, col=0):
        system('mode con cols=%s lines=%s' % (len1, hgt))
        system('title %s' % til)
        system('color %s' % col)
    

提交回复
热议问题