Basic Environment Test for Python Programming

Source: Internet
Author: User

Python programming is an indispensable language for our current programming environment. We have a lot of problems to solve when using them. Let's take a look at how to learn related technologies. I hope this will help you in the future.

Python programming is a powerful object-oriented Interpretation Language. As one master said: it is not only a healthy thing, but also suitable for big projects. You can freely expand the development kit to support all the functions you want to implement. In the article "How To Be a hacker", the author listed Python as one of the four programming languages necessary for hackers (the other three are C, Lisp, and Perl ). the authors of Think in C ++ and Think in Java also strongly advocate the use of Python programming. It is really not good! Python is really good, really!

Python programming environment

Installing python is very simple. Installing Python on WINDOWS is the same as installing other programs on Windows. Download Python for Windows. You can get a lot, including the complete online documentation. After the installation is successful, the system automatically sets the environment parameters and associates them with all scripts that can be recognized by Python. the icons of other files are snakes ). Therefore, you don't need anything else. You just need to use your notepad to write the python program, and then save it. if py is a file with a suffix, double-click the file to automatically execute the program you wrote! Installing on a UNIX-Like system is not a problem. In addition, many Linux versions have added python programming to the channel system by default. You only need to test whether it works properly:

Try it out: If python (Press ENTER) appears

 
 
  1. Python 2.2.2 (#1, Feb 24 2003, 19:13:11) [GCC 3.2.2 
    20030222 (Red Hat Linux 3.2.2-4)] on linux2 Type "help", 
    "copyright", "credits" or "license" for more information. >>>  

So, python has been installed on your system. If it does not appear, download the rpm package or compile and install the source code. It is clear how to compile the README document in the source code package. The Python code is platform-independent. The python code you write on Windows can be executed on the same way as the Code sent to your friends on linux!

Simple demonstration of Python Programming

This is a very simple python program. Its function is to search for your input string from a file and then output the row to be found. The function is like grep.

 
 
  1. #!/usr/bin/python   
  2. if __name__=='__main__':   
  3. file_name = raw_input('Input the file you want to find in:')   
  4. try:   
  5. in_file = open(file_name,'r')   
  6. lines = in_file.readlines()   
  7. tag_tok = ''   
  8. while tag_tok.upper() != 'Q':   
  9. tag_tok = raw_input('Input the word you want to find(Q for quit):')   
  10. if tag_tok.upper() != 'Q':   
  11. count = 0   
  12. line_no = 0   
  13. for line in lines:   
  14. line_noline_no = line_no + 1   
  15. inline_cnt = line.count(tag_tok)   
  16. countcount = count + inline_cnt   
  17. if inline_cnt > 0:   
  18. print 'Find %s %d time(s) in line :%d'%(tag_tok,inline_cnt,line_no)   
  19. print line   
  20. print '---------------------------------'   
  21. print 'Total fount %s %d time(s)'%(tag_tok, count)   
  22. except:   
  23. print "Can't open file %s"%(file_name)   

This is a very simple program. I think anyone who has learned programming has written it. Maybe you wrote it in C just like me, later, maybe you wrote it again in C ++, or even later in JAVA, and you wrote it again in JAVA. However, those languages are not as simple as those written in python.

  • Summary of Python programming skills
  • Python programming language with simplified read flexibility
  • Measure the test taker's knowledge about the Python programming language in a short time.
  • Describes the Python programming language.
  • Summary of the entire process of Python programming skills

Python express connect

How to program in Python? I will show how I walked all the way later, but I cannot write such detailed documents, because I am still exploring! Haha. There is an online manual, and the translation is not satisfactory, but I am not satisfied with it. It is not about the translation but about the content. . . . . . But it is really suitable for getting started! If you are still looking at the door, there is an email list. It is said to be the most authoritative python organization in China. You can check it out if you want!

Python is a powerful object-oriented Interpretation Language. As one master said: it is not only a healthy thing, but also suitable for big projects. You can freely expand the development kit to support all the functions you want to implement. In the article "How To Be a hacker", the author listed Python as one of the four programming languages necessary for hackers (the other three are C, Lisp, and Perl ). the authors of Think in C ++ and Think in Java also strongly advocate the use of Python. It is really not good! Python is really good, really!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.