Read Shebang, just a little shell knowledge, never again do not have obsessive-compulsive disorder

Source: Internet
Author: User
Tags shebang

Python2:

To open a terminal, enter the following command:

[Email protected]:~$ vim helloa.py

In the Vim editor, enter edit mode (press i), enter the following code, and then exit edit mode (press ESC), save the file (press shift+ semicolon, and then press WQ to save the exit)

1  # !/usr/bin/python 2   3   Print " Hello Python2 " 4   Print 5/2

Then change the file executable permissions

[Email protected]:~$ chmod +x helloa.py

Then you can safely execute the helloa.py, just as you do other commands.

Python3:

With similar steps, we can enter a similar code like the following

1 # !/usr/bin/python3 2  3 Print ("hello python3") 4 Print (5/2)

The results of the implementation are as follows:

Summary, the first line in the Python code to #! The beginning, called Shebang, points to a script parser, which is consistent with writing shell scripts, and with this line we can use the script as a command.

Read Shebang, just a little bit of shell knowledge, never again do not have obsessive-compulsive disorder

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.