诺丶辰 发表于 2022-5-19 13:59:55

easygui代码出错

import easygui as g
import sys

while 1:
      g.msgbox("嗨,欢迎进入第一个界面小游戏^_^")

      msg ="请问你希望在鱼C工作室学习到什么知识呢?"
      title = "小游戏互动"
      choices = ["谈恋爱", "编程", "OOXX", "琴棋书画"]
      
      choice = g.choicebox(msg, title, choices)

      # 注意,msgbox的参数是一个字符串
      # 如果用户选择Cancel,该函数返回None
      g.msgbox("你的选择是: " + str(choice), "结果")

      msg = "你希望重新开始小游戏吗?"
      title = "请选择"

      # 弹出一个Continue/Cancel对话框
      if g.ccbox(msg, title):
                pass            # 如果用户选择Continue
      else:
                sys.exit(0)   # 如果用户选择Cancel



-----------------------------------------------------------
运行之后就报错了
Traceback (most recent call last):
File "C:\Users\86176\AppData\Local\Programs\Python\Python310\牛不.py", line 11, in <module>
    choice = g.choicebox(msg, title, choices)
File "C:\Users\86176\AppData\Local\Programs\Python\Python310\lib\site-packages\easygui\boxes\choice_box.py", line 38, in choicebox
    mb = ChoiceBox(msg, title, choices, preselect=preselect,
File "C:\Users\86176\AppData\Local\Programs\Python\Python310\lib\site-packages\easygui\boxes\choice_box.py", line 123, in __init__
    preselect_list = make_list_or_none(preselect, cast_type=int)
File "C:\Users\86176\AppData\Local\Programs\Python\Python310\lib\site-packages\easygui\boxes\choice_box.py", line 95, in make_list_or_none
    if not isinstance(obj, collections.Sequence):
AttributeError: module 'collections' has no attribute 'Sequence'

这是为啥

豆嘉木 发表于 2022-5-19 14:11:10

显示是属性错误,但你看这里https://github.com/volatilityfoundation/volatility3/issues/589
不知道现在修复了没有,这是python3.10的一个bug
混一个最佳答案{:10_256:}

hrpzcf 发表于 2022-5-19 20:12:45

最新版easygui修复这个问题了,安装最新版就可以了:pip install -U -i https://pypi.tuna.tsinghua.edu.cn/simple easygui
页: [1]
查看完整版本: easygui代码出错