iT邦幫忙

0

python tkinter BUG

各位前輩們安安
小弟我最近在使用tkinter時遇到了一個BUG
debug了很久但實在是不能理解為什麼會出現這個BUG
如圖
https://ithelp.ithome.com.tw/upload/images/20200811/20112748mfCKfEqsKZ.jpg

我更改了userinfo的資料
但是userinfolist的資料卻跟了變動了
如下圖
https://ithelp.ithome.com.tw/upload/images/20200811/20112748y9nOJDuV36.jpg

程式碼檔案在這
https://drive.google.com/file/d/1l1v-dn5K1yeDaFeisLidUmZXKpdUiiMJ/view?usp=sharing

請問一下哪邊出了什麼問題...

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

1
powerc
iT邦新手 1 級 ‧ 2020-08-11 15:37:07
最佳解答
def readcfg(self):
        try:
            self.userinfolist=[{'username': 'zxc123', 'userpsw': '56489', 'remember': 'yes', 'autologin': 'no'}]
            if self.userinfolist :
                self.read=True
                self.userinfo=self.userinfolist[0]
                
            #後面省略

之中的self.userinfo=self.userinfolist[0]
其實只是去參考了位址,沒有另外存成一個變數,所以會互相影響

若要複製一份內容出來
你可以用.copy()[:]list()

zxc512034 iT邦新手 5 級 ‧ 2020-08-11 16:19:23 檢舉

原來是位址沒改變/images/emoticon/emoticon17.gif

打算使用.copy試試

我要發表回答

立即登入回答