How to run py files directly in linux

How to run py files directly in linux

1. First create the file (cd to the directory where it needs to be placed)

touch myTest.py

2. Edit myTest.py

vi myTest.py

Add content inside

#! /usr/bin/env python

Then add the code you need to add

print('hello, world!')

Then enter command mode, :wq save and exit vi

3. Change the permissions of myTest.py as needed. This is mainly used for testing, so do not set it to 777

chmod 777 myTest.py

4. This is to run myTest.py directly in the current directory (similar to directly executing exe in windows)

./myTest.py

The above method of directly running py files in Linux is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • How to call Linux Shell commands under Python
  • How to run Python scripts in the CMD command line
  • Run the .py file in cmd: python steps
  • Implementation of running python files in python shell

<<:  Detailed explanation of JS ES6 coding standards

>>:  Why do select @@session.tx_read_only appear in DB in large quantities?

Recommend

Detailed explanation of three ways to wrap text in el-table header

Table of contents Problem Description Rendering T...

Specific steps to use vant framework in WeChat applet

Table of contents 1. Open the project directory o...

In-depth analysis of Nginx virtual host

Table of contents 1. Virtual Host 1.1 Virtual Hos...

Detailed tutorial on installation and configuration of MySql 5.7.17 winx64

1. Download the software 1. Go to the MySQL offic...

How to use cc.follow for camera tracking in CocosCreator

Cocos Creator version: 2.3.4 Demo download: https...

MySQL batch removes spaces in a certain field

Is there any way to remove spaces from a certain ...

js native carousel plug-in production

This article shares the specific code for the js ...

Problems encountered in using MySQL

Here are some problems encountered in the use of ...

Web page header optimization suggestions

Logo optimization: 1.The logo image should be as ...

Nginx content cache and common parameter configuration details

Use scenarios: The project's pages need to lo...

MySQL service and database management

Table of contents 1. Start and stop service instr...

Implementation steps for building FastDFS file server in Linux

Table of contents 1. Software Package 2. Install ...