Enable python Learning

Source: Internet
Author: User

1. install sudo apt-get install cpython
2. Start: Enter the python. Command Prompt in the command line to >>> to start the python interpreter.
3. >>> print 'aaa' to reference a string.
A simple procedure:
Python 2.6.5 (r265: 79063, Oct 1 2012, 22:07:21)
[GCC 4.4.3] on linux2 www.2cto.com
Type "help", "copyright", "credits" or "license" for more information.
>>> MyString = 'Hello World! '
>>> Print myString
Hello World!
>>> MyString
'Hello World! '
>>> _
'Hello World! '
4. The underscore (_) has a special meaning in the interpreter, indicating the value of the last expression (in the example above)
5. The print Statement of Python can be used in combination with the string format operator (%) to implement string replacement, which is very similar to the printf () function in C:
>>> Print "% s is number % d! "% (" Python ", 1)
Python is number 1!
6. An example of redirecting an output to a log file:
>>> Logfile = open ('/home/administrator/mylog.txt', 'A ')
>>> Print> logfile, 'fatal error: invalid input! '
>>> Logfile. close ()
Use the command cat mylog.txt on another terminal to display 'fatal error :........'
7.

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.