简体   繁体   中英

How to transform lines of code into a comment in Python3

just wondering how to convert a set of code into comments, without having to go through each individual line of code and put a # at the beginning. Was thinking that maybe there was a quick way to highlight the code and then convert it into comment, atm i'm just cutting it off the code and then re-pasting it in later on.

Much appreciated:)

PS im using Pycharm as my IDE

In jupyter notebook , we select lines of code and press ctrl and / key simultaneously to convert a set of code into comments. Also same for vice versa. You can try it in Pycharm .

You can use the (""") symbol before and after the text you want to comment out. It is not exactly a comment and more of a text constant, but either way it is often used for documentation, so you can use it for multiline comments except for some cases when it causes unexpected errors To avoid such cases you could simply use multiple single line comments by selecting the desired lines and using ctrl+/ to comment them out

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM