|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 jzy789 于 2021-11-21 11:09 编辑
如题,
安装好pygal之后import,显示,ImportError: cannot import name 'Iterable' from 'collections'
将collections该成collections.abc后继续报错(如图)
家人们,救命!麻烦大佬们帮帮孩子吧!
- import pygal
- from die import Die
- # 创建一个D6
- die = Die()
- # 掷几次骰子,并将结果储存在一个列表中
- results = []
- for roll_num in range(1000):
- result = die.roll()
- results.append(result)
- # 分析结果
- frequencies = []
- for value in range(1, die.num_sides+1):
- frequnecy = results.count(value)
- frequencies.append(frequnecy)
- # 对结果进行可视化
- hist = pygal.Bar()
- hist.title = 'Results of rolling one D6 1000 times.'
- hist.x_labels = [1, 2, 3, 4, 5, 6]
- hist.x_title = "Result"
- hist.y_title = "Frequency of Result"
- hist.add('D6', frequencies)
- hist.render_to_file("die_visual.svg")
复制代码 |
|