In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
How do I bulk add print parentheses in pycharm using regular expressions? In view of this problem, this article introduces the corresponding analysis and answers in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.
The version of the python code downloaded from the network varies. In the process of migrating python3.x from python2.x, there is a print syntax problem, that is, print has no parentheses in python2.x and print has parentheses in python3.x.
Adding parentheses line by line is inefficient, so regular expressions can be used to provide a solution.
1. In the pycharm compiler, Ctrl+R calls up the replacement function box, checks "Regex", and selects the regular expression replacement method.
2. From top to bottom, enter in the first search box
Print (. *); $
The meaning of regular expression. Matches any character except newline characters when the re.DOTALL tag is specified can match any character including newline characters * match 0 or more expressions? Matches 0 or 1 fragments defined by the previous regular expression, matches the expression in parentheses in a non-greedy way, and also represents a group; matches the semicolon (although no semicolon can be added at the end of the expression in Python, but someone will inevitably add) $matches the end of the input string
Statement meaning: match all parts of the print statement and get the contents of the print in the first parenthesis
The second replacement box input
Print (. *)
Sentence meaning: replace, and the content in the parentheses after the replacement is the content in the first parenthesis obtained earlier.
3. Click Replace all to replace all search results and complete the replacement.
This is the answer to the question about how to use regular expressions to add print parentheses in bulk in pycharm. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.