python程序报错问题集
Victor_Gui
这个作者很懒,什么都没留下…
展开
-
完美解决module 'matplotlib' has no attribute 'artist' 以及 module 'pandas' has no attribute 'compat'的解决办法
在运行程序的时候突然发现了这两个问题:module ‘matplotlib’ has no attribute ‘artist’ 以及 module ‘pandas’ has no attribute ‘compat’,苦苦查询了很久,刚开始重新下载pandas包发现不起作用,最后发现错误根源在于matplotlib,于是重新升级matplotlib到3.0.2版本就行了。anaconda代码:...原创 2019-02-26 14:43:46 · 14700 阅读 · 3 评论 -
python import不同(相同)文件夹(目录)下的文件
(1)import不同文件夹下的文件如果这文件不在一个路径下面,import就比较麻烦了,需要在被import的文件路径下面新建一个__init__.py文件,光创建就行,不需要往里面添加内容。比如被import的文件路径是…A/b.py下面,那么只要在文件夹A下面分别新建一个__init__.py文件,然后按照下面的语句引用即可:import A.b(2)import相同文件夹下的文件...原创 2019-04-08 16:19:38 · 34486 阅读 · 2 评论 -
[python]判断列表是否为空的循环条件 while list: 和 while list is not None:的区别
(1)while list:当X为None, False, 空字符串"", 0, 空列表[], 空字典{}, 空元组()这些时,X为假,当X里面有元素时,X为真。例如:list1 = []list2 = ['hello']while list1: print('list1') breakwhile list2: print('list2') break...原创 2019-04-13 09:04:40 · 8514 阅读 · 1 评论 -
RuntimeError: output with shape [1, 28, 28] doesn't match the broadcast shape [3, 28, 28]
RuntimeError: output with shape [1, 28, 28] doesn’t match the broadcast shape [3, 28, 28]在用pytorch导入mnist数据时出现了上述错误,报错程序:transform = transforms.Compose([ transforms.ToTensor(), transforms.Normal...原创 2019-05-14 10:01:50 · 14358 阅读 · 11 评论