看板 Python 關於我們 聯絡資訊
請問一下於python 2.7 中 self.currentini = {'debug' : 'on'} def verify_currentlyini(self,(key,value)): self.currentini[str(key).split('$')[1]]=str(value) 但是更改python 3.6 self.currentini = {'debug' : 'on'} def verify_currentlyini(self,key,value): self.currentini[str(key).split('$')[1]]=str(value) TypeError: modify_currentlyini() missing 1 required positional argument: 'value' 請問大家該如何更改我的程式 ? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.200.200.9 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1530624366.A.149.html
HenryLiKing: 參數改成 tuple嗎? 07/03 21:33
djshen: 可以參考2to3怎麼改 07/03 23:32
adrianshum: 和2 to 3 沒關係吧,method signature 整個不一樣了 07/04 09:14
pmove: 推1F,改成(key, value) 07/04 09:27
djshen: 不就是因為python3拿掉這種unpacking才要改嗎 07/04 11:18
djshen: 不然他原本就是這樣寫阿 07/04 11:19
pmove: 傳進去的東西就不能是tuple , 而要拆開來傳 07/04 13:16
djshen: 改function容易還是改所有用到function的地方容易? 07/04 14:26
djshen: 哪有什麼傳進去的東西就不能是tuple 07/04 14:27
Sunal: function用一個參數接 在function裡面分別取出不就好了 07/04 15:08
splasky: 你可以用decorator 07/04 22:33
wayne670225: 多謝大家, python 3.7 傳進去的東西就不能是tuple 07/12 08:42
wayne670225: 最後拆開來傳,結果沒有問題 07/12 08:43
wayne670225: https://www.python.org/dev/peps/pep-3113/ 07/12 08:43