零.格式化工具文档
1 . Black Ignoring sections功能
2 . autopep8 disabling-line-by-line功能;;–line-range选项
3 . Prettier prettier-ignore功能(例:适用于JS的// prettier-ignore
,适用于CSS的/* prettier-ignore */
);;.prettierignore配置文件;;–ignore-path功能
一.实例代码
使用VSCode编辑下面的未格式化的Python代码(格式化工具为Black)
# -*- coding: utf-8 -*-
# Author: qq_39124701
# File: testBlack.pydef print_text( test ) :print(test)# fmt: off
ZHCHARS = ["川", "鄂","赣","甘","贵","桂","黑","沪","冀","津","京","吉","辽","鲁","蒙","闽","宁","青","琼","陕","苏","晋","皖","湘","新","豫","渝","粤","云","藏","浙"]
CHARS = ["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S","T","U","V","W","X","Y","Z"]
# fmt: onCHARS = ["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S","T","U","V","W","X","Y","Z"]print_text(CHARS)
使用Shift+Alt+F
快捷键格式化文档后,效果如下(fmt包裹的代码没有被格式化)
# -*- coding: utf-8 -*-
# Author: qq_39124701
# File: testBlack.pydef print_text(test):print(test)# fmt: off
ZHCHARS = ["川", "鄂","赣","甘","贵","桂","黑","沪","冀","津","京","吉","辽","鲁","蒙","闽","宁","青","琼","陕","苏","晋","皖","湘","新","豫","渝","粤","云","藏","浙"]
CHARS = ["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S","T","U","V","W","X","Y","Z"]
# fmt: onCHARS = ["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S","T","U","V","W","X","Y","Z",
]print_text(CHARS)