
python 常见问题
yanhe156
这个作者很懒,什么都没留下…
展开
-
python 引入模块问题
当要引入的模块有多级目录时,每一级都要有一个__init__.py 问 如有: a/b/c/d.py import a.b.c.d 时需要在 a,b,c,d下都有__init__.py要引入指定目录下的模块时,可以设置环境变量 PYTHONPATH, 添加上指定目录即可。然后执行python时,import syssys.path即可看到python会去搜索模块的路径...原创 2018-05-01 22:27:41 · 288 阅读 · 0 评论 -
pytho lambda 没有参数
第一次看到这种用法,感觉很新奇。func = lambda: x**2funcfunc()报错:func = lambda: x**2x = 4print(func())x = 6print(func())lambda: x... 表示的就是一个没有参数的函数,但是有返回值的函数。...原创 2019-05-25 23:43:10 · 4425 阅读 · 2 评论 -
更新python后pip无法使用?
更新python版本参考https://www.linuxidc.com/Linux/2017-12/149913.htm。注意两点:apt-get需要先安装 sudo apt-get install libssl-dev出现以下错误时Traceback (most recent call last): File "/usr/bin/lsb_release", line...原创 2018-11-01 23:38:02 · 1476 阅读 · 0 评论 -
jupyter notebook中使用pyplot时报错Could not create write struct
https://stackoverflow.com/questions/13817940/matplotlib-and-libpng-issues-with-ipython-notebookFor me putting%matplotlib inlinebefore all matplotlib imports resolved this issue.在第一行加上%matplotlib i...翻译 2018-10-13 14:13:35 · 349 阅读 · 0 评论 -
python 添加注释后报错 unexpected indent
多行注释符号本身也需要注意缩进。 下面的内容会根据上面的多行注释符号来判断缩进对齐是否正确。 Python对缩进要求很严格的。转载 2018-05-03 22:40:50 · 8444 阅读 · 2 评论