In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Most people do not understand the knowledge points of this article "python how to use goto to jump to the specified line of code", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "python how to use goto to jump to the specified line of code" article.
1. The reason is to encounter such a problem in the actual development:
The following is the pseudo code
If embedding.model is not exist: calculate embedding # # moudel_1 save embedding.modelelse: embedding = load embedding.modeltry: use embeddingexcept KeyError: calculate embedding # # this is the same as moudel_1.
Find that you need to paste the previously written calculate embedding in except.
The simple summary is as follows:
Somecode_1try: somecode_2except: somecode_3 somecode_1 # # re-execute 2. Use goto (1) to install gotopip install goto-statement (2) use goto to complete a small example
Define function
From goto import with_goto@with_goto # must have def test (list_): tmp_list = list_ label.begin # identifies where to jump and start execution result = [] try: for I J in enumerate (list_): tmp = 1 / j result.append (tmp) last_right_i = i except ZeroDivisionError: del tmp_ list [last _ right_i + 1] goto.begin # start return result where there is a jump mark
Running
A = test ([1,3,4,0,6]) print (a)
Result
[1.0, 0.3333333333333333, 0.25, 0.16666666666666666]
Note: if you run label and goto on ide Mountain, there is a red wavy line error. You don't have to worry about it and just execute it.
Add: Pycharm jumps back to the previous line of code
I've been writing Python code in Pycharm for some time, and there's a problem that has been bothering me: I often need to jump from one function to another when browsing the code, and sometimes the two functions are so far away that I don't know how to get back to the last function directly.
So my approach is to press ctr+F and then enter the function name of the previous function to locate and return to the previous function.
The above is about the content of this article on "how python uses goto to jump to a specified line of code". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please 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.
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.