自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(49)
  • 收藏
  • 关注

原创 Ubuntu鼠标变十字 不能点击

出现这种情况,应该是bash 直接运行了python文件系统中出现了一个import 进程.python文件中除了注释应该是import在最前边ps -ef|grep import可以查看系统中的这个进程you 9541 9538 0 15:49 pts/2 00:00:00 [import] <defunct>you 17627 17624 0...

2018-10-26 15:59:00 1240

原创 threading python2 和python3

from __future__ import division from __future__ import print_function ...

2018-10-25 17:53:33 1020

原创 linux job

通常运行的进程 ctrl-z之后会暂停到后台bash test.shLinux-4.15.0-36-generic-x86_64-with-Ubuntu-16.04-xenial#39~16.04.1-Ubuntu SMP Tue Sep 25 08:59:23 UTC 2018('64bit', 'ELF')Python:2.7.12 (default, Dec 4 2017, 1...

2018-10-25 17:27:13 413

原创 linux信号列表

kill -l1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR111) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM16) SIGSTKFLT 17) S...

2018-10-25 15:22:30 218

原创 fatal error: sqlite3.h: No such file or directory

编译带有sqlite3的数据库c语言程序时,出现fatal error: sqlite3.h: No such file or directory,找不到头文件的问题。应该是是系统没有安装函数库。在Ubuntu 中这样安装执行下面语句解决:sudo apt-get install libsqlite3-dev...

2018-10-25 15:12:18 930

原创 Python

python2中的字典有has_key方法,python3中删除了if dict.has_key(your_key):改成if your_key in dict:

2018-10-24 17:53:45 165

原创 Python

python2中的字典有has_key方法,python3中删除了if dict.has_key(your_key):改成if your_key in dict:

2018-10-24 17:46:40 153

原创 Python AttributeError: module 'string' has no attribute 'atoi'

python2 中可以用string.atoi 在python3中会报错替换的方案是string.atoi(your_str)替换为int(your_str)这个代码python2和python3都可以运行.

2018-10-19 11:09:36 7247

原创 linux中的分号 && ||

几个符号的用法; 顺序地独立执行各条命令, 彼此之间不关心是否失败, 所有命令都会执行。&& 顺序执行各条命令, 只有当前一个执行成功时候, 才执行后面的。& 放在启动参数后面表示设置此进程为后台进程|| 顺序执行各条命令, 只有当前面一个执行失败的时候, 才执行后面的。| 上一条命令的输出,作为下一条命令参数“;”分号用法用;号隔...

2018-10-17 18:03:07 382

原创 linux updatedb: can not open a temporary file for `/var/lib/mlocate/mlocate.db'

我们想查找我们最新创建的文件时,由于locate的数据库是每天更新.所以我们新创建的文件还没有被更新到系统的数据库.这是需要手动更新数据库. 然后就可以查到.updatedb输出updatedb: can not open a temporary file for `/var/lib/mlocate/mlocate.db'这个错误的原因是因为权限不够要这样手动更新sudo upd...

2018-10-17 17:51:05 1528

原创 linux命令中find, which、whereis、locate,有什么区别?

whatis 用于查询一个命令执行什么功能,并将查询结果打印到终端上which 查看可执行文件的位置whereis 查看文件的位置man Linux提供了丰富的帮助手册,当你需要查看某个命令的参数时不必到处上网查找,只要man一下即可locate 配 合数据库查看文件位置find 实际搜寻硬盘查询文件名称type ...

2018-10-17 17:46:49 985

原创 Linux Ubuntu stty 使用

stty(set tty)命令用于显示和修改当前注册的终端的属性。该命令是一个用来改变并打印终端行设置的常用命令。stty -a #将所有选项设置的当前状态写到标准输出中old_stty_settings=stty -g #保存当前设置stty “$old_stty_settings” #恢复当前设置stty -echo #禁止回显,当您在键盘上输入时,并不出现在屏幕上stty ech...

2018-10-17 15:57:13 1008

原创 Ubuntu mysql安装与使用

Ubuntu 下安装 mysql运行下面的shell代码#安装mysql sudo apt-get -y install mysql-server sudo apt-get -y install mysql-client sudo apt-get -y install libmysqlclient-dev 安装过程中会提示你创建root账户那就创建 要把root...

2018-10-17 14:38:02 1081

原创 python3.5 安装mysqlclient

python 3.5 安装 mysqlclient 会失败pip install mysqlclient注意这里环境中只有python3.5会出现一大堆红字 编译终止,error: command ‘x86_64-linux-gnu-gcc’ failed with exit status 1这个问题的主要原因呢是pip install mysqlclientMySQLdb 现在还...

2018-10-17 13:15:27 641

原创 python mysqlclient安装失败 Command "python setup.py egg_info" failed with error code 1

python2 python3 中代码pip install mysqlclient都安装失败的话,很有可能是你的操作系统中没有安装mysql如果确定已经安装了,请忽略下面的内容.Ubuntu 下安装 mysql的方法sudo apt-get -y install mysql-server sud...

2018-10-17 13:05:23 2843

原创 python write() argument must be str, not bytes

python picklefrom __future__ import absolute_import from __future__ import division from __future__ import print_function import pickle dic = { "key" : "111", ...

2018-10-15 21:59:15 2211

原创 Python hashlib Unicode-objects must be encoded before hashing

Python2中没有这个问题python3中hashlib.md5(data)函数中data 参数的类型应该是byteshash前必须把数据转换成bytes类型Python 2.7.12 (default, Dec 4 2017, 14:50:18) [GCC 5.4.0 20160609] on linux2Type "help", "copyright", "credits" o...

2018-10-15 20:36:29 291

原创 TypeError: Error when calling the metaclass bases Cannot create a consistent method resolution

PythonError when calling the metaclass bases Cannot create a consistent method resolution order (MRO) for bases这个异常 看下代码应该是多重继承中类的顺序导致的.原因是在写多重继承的时候,父类的顺序导致了python的方法解析顺序出现了问题.可将继承父类的顺序调换一下,测试代码应该...

2018-10-15 17:53:36 1293

原创 Python ImportError: cannot import name ABC

Python 3.5.2 测试可以运行import sys from abc import ABC,abstractmethod ...

2018-10-10 19:03:07 3875

原创 Python NameError:name ‘xrange’ is not defined

在python3 中会出这个问题,而xrange( )函数时在python 2.x中的一个函数,在Python 3中,range()的实现方式与xrange()函数相同,所以就不存在专用的xrange( )解决方法1. 在python 3 中运行 将xrange()函数换成range()2. 在python2中运行要兼容的话 自己想办法...

2018-10-10 01:25:32 392

原创 Python import commands ImportError: No module named 'commands'

ImportError: No module named ‘commands’在Python3中执行shell脚本,想要获取其执行状态和标准输出、错误输出的数据,遇到这个错误,原因是commands模块已经被subprocess取代了Deprecated since version 2.6: The commands module has been removed in Python 3.0...

2018-10-10 00:54:59 6413

原创 Python3 TypeError: initial_value must be str or None, not bytes

response.read() returns an instance of bytes while StringIO is an in-memory stream for text only. Use BytesIO instead.The StringIO and cStringIO modules are gone. Instead, import the io module and us...

2018-10-10 00:50:26 1890

原创 Python import urllib2 ImportError: No module named 'urllib2'

python3import urllib2 import urllib2ImportError: No module named 'urllib2'python3.3里面,用urllib.request 代替 urllib2,所以可以这样兼容python2 和python3import sysif sys.version > '3': import urllib.re...

2018-10-09 23:12:47 961

原创 Python import cStringIO ImportError: No module named 'cStringIO'

From Python 3.0 changelog;The StringIO and cStringIO modules are gone. Instead, import the io module and use io.StringIO or io.BytesIO for text and data respectively.From the Python 3 email document...

2018-10-09 22:57:25 8546

原创 Python Linux Ubuntu apt安装PyCharm

PyCharm一个是Python集成开发环境,它既提供收费的专业版,也提供免费的社区版本。PyCharm带有一整套可以帮助用户在使用Python语言开发时提高其效率的工具,比如调试、语法高亮、Project管理、代码跳转、自动完成、单元测试。PyCharm非常好用,而且是跨平台的。PyCharm网址:http://www.jetbrains.com/pycharm/添加源:$ sudo a...

2018-10-09 14:52:35 476

原创 Python ValueError: Attempted relative import in non-package Relative import相对引用 错误

包含相对路径import的python脚本不能直接运行,只能作为module被引用。例如from . import mod1有这样代码的文件只能最为moulule为不能直接运行。相对路径就是相对于module的路径,如果直接运行脚本,这个module的那么就是"main",而不是module原来的name,这样相对路径就不是原来的相对路径了,导入就会失败,出现ValueError: A...

2018-10-09 14:03:50 2804

原创 Python pylint的安装和使用

什么是pylint?Pylint 是一个 Python 代码分析工具,它分析 Python 代码中的错误,查找不符合代码风格标准和有潜在问题的代码。Pylint 是一个 Python 工具,除了平常代码分析工具的作用之外,它提供了更多的功能:如检查一行代码的长度,变量名是否符合命名标准,一个声明过的接口是否被真正实现等等。Pylint 的一个很大的好处是它的高可配置性,高可定制性,并且可以很...

2018-10-08 22:38:52 21687

原创 Python pylint requires Python '>=3.4.*' but the running Python is 2.7.12

用pylint 1.9.x 安装 pip install pylint==1.9.3.或者换源pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade pylint==1.9.3 应该是可以安装成功下面是stackoverflow上的问答How can I install the pylint for pyt...

2018-10-08 20:02:32 9239

原创 vim vi 高亮第80列 Python PEP8规范 行最大长度设置

命令模式下:set cc=80或者 打开 vim的配置 文件 .vimrcvim ~/.vimrc接着你会看到你的配置文件在配置文件中加上这样行配置代码set cc=80ok 现在退出vim 重新打开一个文件,就会看到一个80列的提示了。如果你喜欢可以设置成50set cc=50as you like.这个只是提示,不会强制换行。...

2018-10-08 19:29:21 2777

原创 Kill杀死Linux中的defunct进程(僵尸进程)

一、什么是defunct进程(僵尸进程)?在 Linux 系统中,一个进程结束了,但是他的父进程没有等待(调用wait / waitpid)他,那么他将变成一个僵尸进程。当用ps命令观察进程的执行状态时,看到这些进程的状态栏为defunct。僵尸进程是一个早已死亡的进程,但在进程表(processs table)中仍占了一个位置(slot)。但是如果该进程的父进程已经先结束了,那么该进程就不会...

2018-10-08 17:17:50 36426 2

原创 Python import Queue ImportError: No module named 'Queue'

python3 中引入Queue 会报出这个问题python3 中这样引入import queuepython2 中这样引入import Queue为了兼容 可以这样import sysif sys.version > '3': import queue as Queueelse: import Queue...

2018-10-07 22:50:14 18587 2

原创 Python ctypes

Python 和 C 的混合编程工具有很多,这里介绍 Python 标准库自带的 ctypes 模块的使用方法。初识Python 的 ctypes 要使用 C 函数,需要先将 C 编译成动态链接库的形式,即 Windows 下的 .dll 文件,或者 Linux 下的 .so 文件。来看一下 ctypes 怎么使用 C 标准库。Windows 系统下的 C 标准库动态链接文件为 msvcrt....

2018-10-07 17:20:22 293

原创 Python super(Todo,self).__init__() TypeError: super() argument 1 must be type, not classobj

示例如下class A(): def __init__(self):passclass B(A): def __init__(self): super(A, self).__init__()当调用B创建对象时,会出现错误TypeError: super() argument 1 must be type, not classobjpytho...

2018-10-07 16:00:40 1271

原创 Python NameError: name 'unicode' is not defined

Python2 的unicode 函数在 Python3 中被命名为 str。在 Python3 中使用 ·str 来代替 Python2 中的 unicode.

2018-10-07 12:57:42 3703

原创 Python AttributeError: module 'sys' has no attribute 'setdefaultencoding'

Python 3 与 Python 2 有很大的区别,其中Python 3 系统默认使用的就是utf-8编码。所以,对于使用的是Python 3 的情况,就不需要sys.setdefaultencoding(“utf-8”)这段代码。最重要的是,Python 3 的 sys 库里面已经没有 setdefaultencoding() 函数了。...

2018-10-07 12:38:43 7975

原创 Python reload(sys) NameError: name 'reload' is not defined

对于 Python 2.X:import sysreload(sys)sys.setdefaultencoding("utf-8")对于 <= Python 3.3:import impimp.reload(sys)注意:Python 3 与 Python 2 有很大的区别,其中Python 3 系统默认使用的就是utf-8编码。所以,对于使用的是Python 3 的...

2018-10-07 12:36:38 1058

原创 Python 语法错误 except Exception, e: ^ SyntaxError: invalid syntax

出这个问题是因为python2和python3 语法有些不同python2 和 3 处理 except 子句的语法有点不同,需要注意;Python2try: print ("hello world")except ZeroDivisionError, err:      # , 加原因参数名称 print ('Exception: ', err)Python3try...

2018-10-07 12:26:57 46132 3

原创 Python 调用上级目录的文件

程序结构如下:– src|-- mod1.py|-- lib| |-- mod2.py|-- sub| |-- test.py具体代码如下:在test.py里调用mod1 mod2import syssys.path.append("..")import mod1import mod2.mod2...

2018-10-07 11:25:09 6851 2

原创 Python 检查当前运行的python版本 python2 python3

检查当前运行的python版本,可以帮助程序选择运行python2还是python3的代码import sysif sys.version > '3': PY3 = Trueelse: PY3 = False或者写成函数def isPython3(): import sys if sys.version > '3': return True return Fa...

2018-10-07 11:10:36 4875 2

原创 Python gpu 显卡小工具 gpu

安装pip install gpustat或者 换源pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade gpustat使用gpustat -cpu或者watch --color -n1 gpustat -cpu显示输出

2018-10-06 22:55:31 1072

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除