pycharm整理代码格式_pycharm怎么变成黑色

pycharm整理代码格式_pycharm怎么变成黑色black简介自动的代码格式化工具,兼容pep8,项目地址为:官方给出的简介:BlackistheuncompromisingPythoncodeformatter.Byusingit,youagreetocedecontroloverminutiaeofhand-formatting.Inreturn,Blackgivesyouspeed,determinism,andfreedomfrompycodestylenaggingabo

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全家桶1年46,售后保障稳定

black 简介

自动的代码格式化工具,兼容 pep8,项目地址为:

black项目地址

官方给出的简介:

Black is the uncompromising Python code formatter. By using it, you agree to cede control over minutiae of hand-formatting. In return, Black gives you speed, determinism, and freedom from pycodestyle nagging about formatting. You will save time and mental energy for more important matters.

Blackened code looks the same regardless of the project you’re reading. Formatting becomes transparent after a while and you can focus on the content instead.

Black makes code review faster by producing the smallest diffs possible.

安装命令

pip3 install black

Jetbrains全家桶1年46,售后保障稳定

使用方法

终端中直接运行

在终端中直接将 black 作为命令来运行,如下截图所示:

终端运行结果

运行成功会有输出提示格式化情况。

PyCharm中配置快捷方式运行

打开路径:

PyCharm→Preferences→Tools→External tool

点击+ 后,输入下面的配置:

配置示例

# Program
$PyInterpreterDirectory$/python3
# Arguments
-m black $FilePath$
# Working directory
$ProjectFileDir$

然后配置快捷键,打开下面的目录

PyCharm→Preferences→keymap→External Tools→black

右键点击 Add Keyboard Shortcut ,如下图设置快捷键:

在这里插入图片描述

成功后,运行快捷方式,会直接格式化你所在窗口的 .py 文件。同样在终端中会显示格式化结果。

PEP8 代码格式

可以参考如下博客:
PEP8简介

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/209954.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号