看板 Python 關於我們 聯絡資訊
1.call by ref:(偽) def swap(x,y): return y,x x=1 y=2 x,y=swap(x,y) 2.看不懂你的code 跟call by ref有啥關係 def fun(x): return x+1 fun(5) 就可以 ※ 引述《jimmylin212 (JimmyG)》之銘言: : 想請問在 Python 當中可以 call by reference 嗎? : def Function(x): : x + 1 : x = 5 : Function(x) : 不知道要怎麼讓輸出是 6 : 還沒有改變成 Python 腦 : 感謝各位了 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.168.75.189
dos792:http://0rz.tw/OMttJ 有解釋 call by ref 11/10 21:22
※ 編輯: dos792 來自: 118.168.75.189 (11/10 21:29)
jimmylin212:感謝了!我想通了 11/10 21:32
StubbornLin:http://0rz.tw/yHWxE 看那連結我不小心看到這個... 11/11 00:02
StubbornLin:Don’t try this at home, kids! XDDDD 真好笑 11/11 00:02
a761007:x, y = y, x 11/11 01:00
seedman:1.你乾脆直接 return y,x就好 11/12 19:06
※ 編輯: dos792 來自: 111.184.246.174 (11/13 20:46)
dos792:u r right. that is a better way. 11/13 20:47
mythnc:還以為原po是故意的。因為寫個「偽」字 XD 11/14 16:41
dos792:因為py不搞這套,所以... 11/16 22:53