python
okman312
底层it工作者
展开
-
运行python脚本报错IndentationError: unindent does not match any outer indentation level
运行python脚本报错IndentationError: unindent does not match any outer indentation level查找后发现是空格与tab的对齐问题,将所有tab替换为空格后就可以了。原创 2020-12-08 18:33:08 · 200 阅读 · 0 评论 -
导入psutil报错ImportError: cannot import name ‘_psutil_linux‘ from ‘psutil‘ (/usr/local/src/psutil-5.7
[root@python01 psutil-5.7.3]# python3Python 3.7.9 (default, Sep 8 2020, 13:45:46) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linuxType "help", "copyright", "credits" or "license" for more information.>>> import psutilTraceback (most recent c原创 2020-11-04 19:23:34 · 6296 阅读 · 1 评论 -
vim编辑器tab键设置为4个空格
为了方便写python脚本,可以将tab设置为默认4个空格:[root@python01 ~]# cat .vimrcset ts=4set expandtabset autoindent[root@python01 ~]# source .vimrc参考https://www.cnblogs.com/wenxingxu/p/9510796.html原创 2020-10-31 10:23:28 · 423 阅读 · 0 评论 -
range函数在python2与python3在区别
在python2中的range[root@python01 scripts]# cat sum100.py #/usr/bin/python# -*- coding:UTF-8 -*-number = range(1,101)print(number)[root@python01 scripts]# python sum100.py [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 2原创 2020-09-30 06:52:24 · 302 阅读 · 0 评论