因為在python中,列表、字典等如果只是修改其中元素的值,可以不用gloabl,如果是修改整個列表,必須是有gloabl。
nameList =['Python','Tab','.com'] def func3(): nameList[0] = 'python' func3() print(nameList)
因為在python中,列表、字典等如果只是修改其中元素的值,可以不用gloabl,如果是修改整個列表,必須是有gloabl。
nameList =['Python','Tab','.com'] def func3(): nameList[0] = 'python' func3() print(nameList)
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。