今天使用字符串格式化時,遇到的一點小問題:調用這個方法解釋器出錯了: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)
