python - 在 Ipython 中使用 Pylint (Jupyter-Notebook)
问题描述
我想在使用 Jupyter-Notebook 时运行 Pylint 或任何等效项。有没有办法以这种方式安装和运行 Pylint?
解决方案
pycodestyle相当于pylint
Jupyter Notebook,它能够根据PEP8
样式指南检查您的代码。
首先,您需要通过键入此命令来安装pycodestyle
,jupyter notebook
!pip install pycodestyle pycodestyle_magic
在 jupyter notebook 的单元格中运行此命令。安装成功后,你必须像这样在 Jupyter Notebook 单元中加载魔法,
%load_ext pycodestyle_magic
然后,您必须pycodestyle
在要根据PEP8
标准调查代码的单元格中使用。
以下是一些示例,以便更清晰地理解,
%%pycodestyle
a=1
输出:pycodestyle
会给你这个信息,
2:2: E225 missing whitespace around operator
另一个例子,
%%pycodestyle
def square_of_number(
num1, num2, num3,
num4):
return num1**2, num2**2, num3**2, num4**2
输出:
2:1: E302 expected 2 blank lines, found 0
3:23: W291 trailing whitespace
推荐阅读
- python - PyPubSub 和 PyQt 之间的兼容性
- wcf - 为什么 InstanceContextMode.Single 不起作用?
- css - Adobe EchoSign 嵌入式小部件 iframe 大小
- bash - 需要帮助捕获本身就是 linux bash 中的变量的命令的输出
- javascript - (Angular) 在我的情况下如何返回不同的 Observable 类型请求?
- java - 休眠错误 - 无法构建 ClassFile
- asp.net-mvc - 将查询字符串传递到注册表单
- sql-server - SQL Server 将缺失数据值添加到间隔查询
- python - python excel读取引擎(pandas/read_excel)将布尔值(true/false)转换为float(1.0/0.0)以获取不完整的列
- android - 连接到 Firebase 时出现错误对话框,对话框中的消息是“找不到应用程序”