Use python in Linux Command Line terminal (recommended), linuxpython

Source: Internet
Author: User

Use python in Linux Command Line terminal (recommended), linuxpython

All operations on Linux terminals are performed using the command line. Therefore, for Tom, note several basic command lines and usage methods to quickly use python in the Linux Command Line environment.

Open the command line window

The shortcut for opening the command line window is as follows:

Ctrl + Alt + t

Close command line window

The shortcut for closing the command line window is as follows:

Ctrl + d

Enter the python Environment

Directly input python in the command line to enter the python editing environment. The most obvious prompt after entering the environment is: the cursor from ~ $ Change to >>>.

Exit the python Environment

Use ctrl + d to exit the python environment. Return to the command line environment.

Input Multiple Functions in the python Environment

In the python environment, press enter to end the input and execute the statement. When multiple-line functions are input, enter a line and press enter to directly run a code sentence instead of the entire function block. Therefore, you must be able to wrap a line but not end the input.

Enter English; \ at the end of the statement to implement line feed.

For example:

def weight_variable(shape): initial = tf.truncated_normal(shape, stddev=0.1);\ return tf.Variable(initial);\

Note: Pay attention to indentation when entering function blocks. Otherwise, an IndentationError: unexpected indent python error is reported.

Non-ascii character xe5 in file solution

Cause:Encoding Error in the program. python supports the acii mode by default, but does not support utf8. Therefore, Chinese comments in the program will cause an Error.

Solution: Add # coding: UTF-8 In the first line of the source code file.

The simple method (recommended) for using python in the Linux Command Line terminal is all the content that I have shared with you. I hope to give you a reference and support for the customer's house.

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.