Python Basics "Second piece" Python operation mode

Source: Internet
Author: User

One Interactive mode
1 #python2 3Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)4 5[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux26 7Type" Help","Copyright","credits" or "License"  forMore information.8 9>>>

As shown above:

where ">>>" is the python interactive command line here directly enter the code to get results

Cases:

Input 2 python operation results

1 >>>1+123 2

Print "This is python! "Prints the output string

Print ' This is python! '   is python! exit Python "exit ()">>> exit ()

Second, the text mode

The so-called text pattern is actually writing the code into a file and then executing it in Python.

To edit a file, enter the following code:

  [[email protected]_server py]#   vim py   2   print   '  

* (Every time you execute a script, it will knock Python to perform the feeling is much more simple, just specify the Python bin path in the file so that each execution will not have to hit Python) *

Of course first determine your python's bin path

View Python command path

which python/usr/bin/python

Python is specified in the file

[Email protected]_server py] # Vim Pytest # !/usr/bin/python Print ' This is python ' Print ' 100+200= ', 100+200 execution results [[email protected]_server py]#  ./pytest   is python100+200= 300

Three, two ways each have advantages and disadvantages

1. Interactive mode

Pros: Get results quickly

Cons: Exit does not save

For short Code testing

2. Text mode

Pros: Code can be saved

Cons: Inconvenient operation

For complex code programming

Python Basics "Second piece" Python operation mode

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.