In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how to use Black code formatting tools, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Black
Sometimes creativity can be a wonderful thing. Sometimes it's just a pain. I like to solve problems creatively, but I want my Python format to be as consistent as possible. No one is impressed by the use of "interesting" indented code.
But worse than an inconsistent format is a code review that does nothing but check the format. This is annoying for censors and even more annoying for those being examined. It can also be infuriating when your linter tells you that the code is indented incorrectly but does not indicate the correct amount of indentation.
With Black, it won't tell you what to do, it's a good, hard-working robot: it will fix the code for you.
To understand how it works, feel free to write something very inconsistent, such as:
Def add (a, b): return a+bdef mult (a, b): return\ a * b
Did Black complain? No, it fixed it for you!
$black math reformatted mathAll done! ✨? ✨ 1 file reformatted.$ cat math def add (a, b): return a + bdef mult (a, b): return a * b
Black does provide the option to report errors rather than fix them, and even to output diff editing styles. These options are useful in continuous integration (CI) systems to force Black to run locally. In addition, if the diff output is recorded in the CI output, you can paste it directly into the patch, so that in rare cases you need to repair the output, but you cannot install Black locally.
$black-- check-- diff bad-- math 2019-04-09 17V 2424 return 22.747815 + 0000415 + math 2019-04-09 1726 Vol 04.269451 + 0000Lou @-1 def add (a, b): return a + b+def add (a, b): + return a + bdef mult (a) B):-return\-a * b + return a * bwould reformat mathAll done!? 1 file would be reformatted.$ echo $? 1 is all the content of the article "how to use the Black Code formatting tool" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.