Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of indentation in python

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you the "sample analysis of indentation in python", which is easy to understand and clear. I hope it can help you solve your doubts. Let me lead you to study and learn the article "sample analysis of indentation in python".

In the process of learning to see demo, suddenly a whim, to add some functions, code from Baidu on the Internet. Copy and paste, compilation failed. The situation is roughly as shown in the picture.

The error is as shown in the following picture

I was stunned when I looked at it. I have no idea what went wrong. I can only blame God for not letting me learn programming (funny). With the attitude of seeking roots, I studied this interesting question.

Then I opened it with ue and saw something like this.

Note that the same text, different software opens and displays the sentence position is not the same.

This phenomenon aroused my curiosity.

So I thought of indentation!

Then I turned on the display symbol function with Notepad++.

Indicates tab indentation

One space, one dot.

As you can see, the print in the first sentence above is indented by tab, and the sentence below is indented by spaces.

The python language has strict requirements for indentation. So I modified it to use tab to compile it. Happy

So, is this the end of the question?

Of course not, blue cat naughty 3000 of the children who grew up have a lot of problems.

For example, can indentation use spaces?

How many spaces can I use?

Can I share it with tab?

In order to verify the appeal, I wrote the following code.

Let's briefly analyze this code.

Show1 () means that you can indent as many spaces as you want, and you can compile as long as you align.

Show2 () indicates that the previous function uses spaces, and the next function can still use tab.

Show3 () is an example of mixing.

Feel it for yourself.

What are the main application areas of python? 1. Cloud computing, typical application OpenStack. 2. WEB front-end development, many large websites are developed by Python. 3. Artificial intelligence applications, which are based on big data's analysis and deep learning, have essentially been unable to leave python. 4. System operation and maintenance project, the standard configuration of automatic operation and maintenance is python+Django/flask. 5. Financial management analysis, quantitative transaction, financial analysis. 6. Big data's analysis.

The above is all the content of the article "sample Analysis of indentation in python". 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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report