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

What is the difference between the for loop of python and java

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

Share

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

This article mainly explains "what is the difference between the for cycle of python and java". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the difference between the for cycle of python and java"?

two。 Boast of python

In the current situation, all apes can see very clearly that all directions are moving towards artificial intelligence, self-driving and other intelligent industries, so the advantages here show that the powerful packaging libraries of python can kill a lot of c-end? is the complexity of java unable to meet the fast and concise development mode? Let's make a simple comparison between java and python:

Installation:

Python:

1 download, install

2 configure Bin directory to environment variable

OR can import python directly using pycharm.

Java:

Download, install

Configure environment variables, configure path,class_path,JAVA_HOME

From the perspective of environment configuration, there is not much difference. Let's start with helloWorld.

Java: public class HelloWorld {public static void main (String [] agrs) {System.out.println ("HelloWorld!");}} python:print 'HelloWorld' 's simplicity doesn't need to be compared.

For cycle of python

Let's compare the for cycle of python and java.

Java: / * create an array * / int [] integers = {1,2,3,4}; / * start traversing * / for (int j = 0; j < integers.length; jacks +) {int I = integers [j]; System.out.println (I);}

Python:

Integers = [1,2,3,4]; for i in integers: print integers

Does it feel particularly simple through the above comparison? You're welcome

three。 Solve the problem

In fact, the biggest problem brought about by python is that the difference between spaces and tab keys can easily lead to the compilation of the whole project. At the beginning, it has been using atom to write Python, and later it uses vim to use plug-ins. Because atom can not effectively solve the problem of spaces, every time a problem has to be found one by one, vim can at least unify the space and the TAB key. But it still can't solve the problem effectively. (this is in the initial learning stage of python. (then the python study ran aground.

My solution to the problem is estimated to be the same as that of most people. Haha, it sounds funny.

four。 Pick up the python again

By chance, I want to learn about crawlers, and then use my old java to write the framework of crawlers (ps: because google has passed, the 'big god' door says it doesn't matter what kind of crawler you use, it can be realized. If you work hard to write a web request, someone else will have a rudimentary urllib library done. In the process of thinking about how to deal with the agent of Java, I suddenly found out that someone else had a urllib2.... Okay, I'll put up with it. But I was devastated by the time it was time to simulate head for header parameters. The code that crackled several classes for dynamic simulation was easily replaced by a single line of code from a request library in python. In particular, I decided to firmly use Python with crawlers, I no longer believe that the learning cost is high, and it is more cumbersome to get another code.

Pat your conscience here and say that you must use python to learn reptiles and stop believing the words of those aunts.

five。 Time cost problem

I am not a very patient person. I will freak out if I don't get results in a short time, so I want to see the results. If you are like me, then congratulations. Python will take you on a tour. The whole person was excited when I used these two sentences to lie down on the entire web page:

Import urllib2 response = urllib2.urlopen ("http://www.baidu.com")print response.read ())

Is it cool that the Htlm of the whole Baidu home page is lying down? That's how it works.

It doesn't matter. Using regular expressions to analyze html text is a headache, but Beautiful Soup saved me again. I really have what I think. So what if I want to submit post data. Request . At least as a rookie, there is no library that I can't find when I use python to write a package project.

Thank you for your reading, the above is the content of "what is the difference between the for cycle of python and java". After the study of this article, I believe you have a deeper understanding of what is the difference between the for cycle of python and java. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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