看板 Python 關於我們 聯絡資訊
我的程式碼如右圖 http://i.imgur.com/sIlZPDD.png 執行結果如右圖 http://i.imgur.com/3i7JEd7.png 我明明是把 a 丟入 function x1 中 為什麼在執行完 x1 後 連b的值也會被改變呢 謝謝 ( Windows 7 Python 3.3.5 ) -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 180.176.219.248 ※ 文章網址: http://www.ptt.cc/bbs/Python/M.1397372097.A.537.html
LiloHuang:a=b 並沒有做拷貝,只是參照,也許 a=b.copy() 是你要的 04/13 15:03
woody3724:成功了!!! 感謝 原來是pass by reference的概念 04/13 15:05