好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

使用python过程出现的细节问题:TypeError: not enough arguments

今天使用字符串格式化时,遇到的一点小问题:调用这个方法解释器出错了: TypeError: not enough arguments for format string

  

def ll(name,age):
    print(‘name:%s,age:%s‘ %name, age)

ll(‘huhu‘,18)

运行结果:

 File "D:/python/pylib.py", line 69, in ll
    print(‘name:%s,age:%s‘ %name, age)
TypeError: not enough arguments for format string

  

正确的写法:

  

def ll(name,age):
    print(‘name:%s,age:%s‘ % (name, age))
ll(‘huhu‘,18)

查看更多关于使用python过程出现的细节问题:TypeError: not enough arguments的详细内容...

  阅读:26次