Python的学习中细节的整理(1)

来源:互联网 发布:儿童节礼物 知乎 编辑:程序博客网 时间:2024/06/07 05:30

This is my first day of engaging myself to the python learning since I have made up mind to master this kind programming language. It took me a lot of time this morning to construct a python development environment on my windows with Eclipse, which is a multifunctional IDE and can also be used for other languages ,such as Java.

For the constructing work, there are 4 main procedures ,ie, the installation of java JDK(or JRE), the python complier installation, the eclipse installation, and the PyDev installation, among which I think there are two piece of  tips should be given an eye on:


***1. be careful with the path variables when installing the java JDK and set the JAVA_HOME variables(include 3 steps:JAVA_HOME setting, path setting, classpath setting),

unless you set the JAVA_HOME in good manner ,or your eclipse may not function well ,the following is the commen case if not setting the JAVA_HOME after installing the java JDK:

and this is how to set JAVA_HOME:  http://jingyan.baidu.com/article/9f7e7ec05bb0ca6f281554c1.html


***2. make sure the bit-version of java JDK and eclipse. I installed these two of 64-bit.

<  note:this is the site from which I learned how to construct python development environment: http://lib.csdn.net/article/python/12326

in my opinion, it's not neccessary for you to make each of these steps very clear ,such as "why conduct this or that step","what this step is for?",and so on, if you are a green hand for eclipse use. What we need to do is just do it ,and you will gradually get why this and why that.  >


in the next part I sumed up some operation details here, they are just a little parts of Python grammer and using tips, and I will supplement them during my learning process.

1. the IDLE(Python GUI) and Windows CMD interface:

the IDLE provides users a convenient interface to code python, you can directly type python sentences, just as the following:

having finished your code , you can :

                                                              1)press Enter button, then the following line of IDLE will show the running results;

                                                               2)save the code with a certain file name , then next time you can open it with sublime text or IDLE, or CMD line(with the command           "python filename.py"),  and run this file.

2. you can use both windows notepad(.txt) and sublime Text to creat a python code file ,howerver, when you choose notepad, keep in mind that the form should be saved asutf-8,and the suffix name as "py",like the following:


3. the difference between directly using CMD interface and using IDLE when compiling python code (take py_1.py as an example) :

     if you choose CMD interface, you can:

                                                                      1) use "python py_1.py" command to run this code, and the result will be on show in the next line of the black pane;

                                                                      2)use "python" command to enter in python console interface,like the fllowing:

                                                                     


<  note: if you want your computer to be able to shift directly from CMD interface to python console interface, you should firstly add thepython.exe installation path to the path variables once you finished installing python(ie.python complier) in your computer.  >


                                                                      in this console interface, you can directly input python code, like <  print "hello",3+4  >,press Enter button, then the next will show the results:

                                         

                                                              if you want to exit this python console interface and return to the previous CMD interface, just input <  quit()  >.




0 0
原创粉丝点击