随笔分类 -  Python(转载)

摘要:Python isinstance() 函数 描述 isinstance() 函数来判断一个对象是否是一个已知的类型,类似 type()。 isinstance() 与 type() 区别: type() 不会认为子类是一种父类类型,不考虑继承关系。 isinstance() 会认为子类是一种父类类 阅读全文
posted @ 2019-06-25 10:33 菜鸡一枚 阅读(1300) 评论(0) 推荐(0) 编辑
摘要:Python代码规范问题及解决 为了养成使用Python编程好习惯,尽量保证自己写的代码符合PEP8代码规范,下面是过程中报出的警告及解决方法,英文有些翻译不太准确见谅,会不断更新: PEP 8 只是检测风格错误,而非编码错误! PEP 8: module level import not at t 阅读全文
posted @ 2019-06-23 19:45 菜鸡一枚 阅读(661) 评论(0) 推荐(0) 编辑
摘要:continuation line under-indented for visual indent 问题:使用flake8检验代码规范时报错:continuation line under-indented for visual indent问题:括号内容的内容要对齐方法:sqss = self. 阅读全文
posted @ 2019-06-23 10:20 菜鸡一枚 阅读(18350) 评论(0) 推荐(1) 编辑
摘要:Pycharm设置 Pycharm总是很多的拼写检查波拉线 Spellchecker inspection helps locate typos and misspelling in your code, comments and literals, and fix them in one clic 阅读全文
posted @ 2019-06-23 10:13 菜鸡一枚 阅读(564) 评论(0) 推荐(0) 编辑
摘要:"PEP:8 expected 2 blank lines ,found 1" pycharm shows "PEP:8 expected 2 blank lines ,found 1" 用pycharm写python的时候,总会在def function()的那行出现如上问题。解决办法:参考了【p 阅读全文
posted @ 2019-06-23 10:06 菜鸡一枚 阅读(875) 评论(0) 推荐(0) 编辑
摘要:Pycharm 字体大小调整 版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/awyyauqpmy/article/details/79334496Pycharm 字体大小调整 一、pycharm字体放大的设置 File —>setting —> K 阅读全文
posted @ 2018-12-05 22:01 菜鸡一枚 阅读(2504) 评论(0) 推荐(0) 编辑
摘要:windows安装anaconda 报错failed to create anacoda menu ? 装了无数次,每次都是 failed to create anacoda menu然后无选择忽略,忽略,忽略,提示安装成功,依旧没有 菜单 进入 cmd,找到你安装的位置(我的是D盘,anacoda 阅读全文
posted @ 2018-11-29 22:20 菜鸡一枚 阅读(6929) 评论(0) 推荐(0) 编辑
摘要:Python数据存储:pickle模块的使用讲解 在机器学习中,我们常常需要把训练好的模型存储起来,这样在进行决策时直接将模型读出,而不需要重新训练模型,这样就大大节约了时间。Python提供的pickle模块就很好地解决了这个问题,它可以序列化对象并保存到磁盘中,并在需要的时候读取出来,任何对象都 阅读全文
posted @ 2018-11-26 16:54 菜鸡一枚 阅读(323) 评论(0) 推荐(0) 编辑
摘要:Python 的 six模块简介 six : Six is a Python 2 and 3 compatibility library Six没有托管在Github上,而是托管在了Bitbucket上,不过这些都不是重点,重点是它的作用。 众所周知 Python 2 和 Python 3 版本的分 阅读全文
posted @ 2018-11-26 10:46 菜鸡一枚 阅读(4045) 评论(0) 推荐(0) 编辑
摘要:【python图像处理】图像的缩放、旋转与翻转 图像的几何变换,如缩放、旋转和翻转等,在图像处理中扮演着重要的角色,python中的Image类分别提供了这些操作的接口函数,下面进行逐一介绍。 1、图像的缩放 图像的缩放使用resize()成员函数,直接在入参中指定缩放后的尺寸即可,示例如下: #- 阅读全文
posted @ 2018-11-17 22:04 菜鸡一枚 阅读(7596) 评论(0) 推荐(0) 编辑
摘要:python 读取文件时报错UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 205: illegal multib 在python3读取txt文件时,遇到上面问题是因为: txt文件存的是utf8编码,打开文件的时 阅读全文
posted @ 2018-11-13 10:54 菜鸡一枚 阅读(492) 评论(0) 推荐(0) 编辑
摘要:NameError:name 'xrange' is not defined NameError:name ‘xrange’ is not defined 在参考别人的关于机器学习《K均值聚类算法》的Python实现的源代码时,当我运行时报了如下错误。 原因是我的python版本为python 3. 阅读全文
posted @ 2018-11-13 10:35 菜鸡一枚 阅读(1190) 评论(0) 推荐(0) 编辑
摘要:TypeError: 'range' object does not support item assignment I was looking at some python 2.x code and attempted to translate it to py 3.x but I'm stuck 阅读全文
posted @ 2018-11-13 10:22 菜鸡一枚 阅读(1097) 评论(0) 推荐(0) 编辑
摘要:17个新手常见Python运行时错误 当初学 Python 时,想要弄懂 Python 的错误信息的含义可能有点复杂。这里列出了常见的的一些让你程序 crash 的运行时错误。 1)忘记在 if , elif , else , for , while , class ,def 声明末尾添加 :(导致 阅读全文
posted @ 2018-11-13 10:11 菜鸡一枚 阅读(353) 评论(0) 推荐(0) 编辑
摘要:Python中【__all__】的用法 转:http://python-china.org/t/725 用 __all__ 暴露接口 Python 可以在模块级别暴露接口: __all__ = ["foo", "bar"] 很多时候这么做还是很有好处的…… 提供了哪些是公开接口的约定 不像 Ruby 阅读全文
posted @ 2018-11-08 20:18 菜鸡一枚 阅读(1830) 评论(0) 推荐(0) 编辑
摘要:图文并茂的Python教程-numpy.pad np.pad()常用与深度学习中的数据预处理,可以将numpy数组按指定的方法填充成指定的形状。 声明: 需要读者了解一点numpy数组的知识np.pad() 对一维数组的填充 import numpy as nparr1D = np.array([1 阅读全文
posted @ 2018-10-27 20:20 菜鸡一枚 阅读(2222) 评论(0) 推荐(0) 编辑
摘要:python中的time模块 time模块--时间获取和转换 阅读全文
posted @ 2018-09-26 08:42 菜鸡一枚 阅读(294) 评论(0) 推荐(0) 编辑
摘要:Difference between plt.draw() and plt.show() in matplotlib down voteaccepted down voteaccepted plt.show() will display the current figure that you are 阅读全文
posted @ 2018-08-15 09:54 菜鸡一枚 阅读(2143) 评论(0) 推荐(0) 编辑
摘要:使用python中的matplotlib 画图,show后关闭窗口,继续运行命令 在用python中的matplotlib 画图时,show()函数总是要放在最后,且它阻止命令继续往下运行,直到1.0.1版本才支持多个show()的使用。想在显示图像后继续运行相关的处理命令,或者显示一副图像后关闭它 阅读全文
posted @ 2018-08-15 09:53 菜鸡一枚 阅读(45005) 评论(0) 推荐(0) 编辑
摘要:使用matplotlib绘制多个图形单独显示 一 代码 import numpy as np import matplotlib.pyplot as plt #创建自变量数组 x= np.linspace(0,2*np.pi,500) #创建函数值数组 y1 = np.sin(x) y2 = np. 阅读全文
posted @ 2018-08-15 09:48 菜鸡一枚 阅读(6506) 评论(0) 推荐(0) 编辑