Re: [問題]關於移植 code from python 2.7 to 3.6
※ 引述《wayne670225 (北極熊在英國)》之銘言:
: 請問一下於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'
: 請問大家該如何更改我的程式 ?
self.currentint = {'debug' : 'on'}
def varify_currentlyini(self, key_value):
key, value = key_value
self.currentini[str(key).split('$')[1]] =str(value)
主要是傳入的時候不能直接宣告他是一個tuple
所以把tuple設成一個變數
讀進來的時候再拆開
以下是範例
def demo(c):
a,b = c
print(b)
demo(('Hello','world'))
-------------------
result: world
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.38.10.187
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1530688219.A.F78.html
※ 編輯: TuCH (114.38.10.187), 07/04/2018 15:11:23
→
07/04 21:45,
7年前
, 1F
07/04 21:45, 1F
→
07/04 21:47,
7年前
, 2F
07/04 21:47, 2F
推
07/04 22:51,
7年前
, 3F
07/04 22:51, 3F
推
07/12 08:46,
7年前
, 4F
07/12 08:46, 4F
→
07/12 08:47,
7年前
, 5F
07/12 08:47, 5F
→
07/12 08:47,
7年前
, 6F
07/12 08:47, 6F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):
Python 近期熱門文章
PTT數位生活區 即時熱門文章