程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python learning notes 002 - simple errors

編輯:Python

Traceback (most recent call last): This is a running error .

Wrong background : Error in function call for multivalued parameter .

When I was practicing this problem , Use tuples as multivalued arguments to functions . When making function calls , There is a misuse of dictionary rules .

1. Dictionary key, You can't use "" contain .

2. Key value pairs are used in the middle = Not the comparison operator ==

It directly leads to the appearance of the top Traceback The reason for the mistake is , Undefined variable name used .

summary :debug Your ability needs to be proficient .

Attach error code :

def demo(num, *args, **kwargs):
print(num)
print(args)
print(kwargs)
print("")
print(" The correct sample ")
demo(1)
demo(1, 2, 3,)
demo(5, 6, 7, name=" Xiao Ming ", age=18)
# Error model
print(" demonstration 1, There is no definition in the code name This variable name , No... Was found during the comparison operation , Therefore, the program reports an error ")
demo(5, 6, 7, name == " Xiao Ming ")
print(" demonstration 2, The result of the comparison operation is a Boolean value ")
demo(5, 6, 7, "name" == " Xiao Ming ")

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved