Get the App
SLTechnology News&Howtos  ›  Development  › 

How to implement Hello World with Python

Shulou Source: shulou.com Published: 2022-06-02 18:43:06 09月25日 Update

This article mainly explains "how to use Python to achieve Hello World", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "how to use Python to achieve Hello World" bar!

Python Command Line

Assuming you have installed Python, type on the Linux command line:

$python

Will go directly to python. Then enter at the command line prompt >

> print ('Hello Worldwide')

As you can see, and then output on the screen:

Hello World!

Print is a common function whose function is to output the string in parentheses.

(in Python 2.x, print can also be a keyword, which can be written as print 'Hello Worldword words, but this doesn't work in 3.x.)

Write a paragraph on Mini Program

Another way to use Python is to write a Python program. Use a text editor to write a .py-ending file, such as hello.py

Write the following in hello.py and save:

Print ('Hello Worldwide')

Exit the text editor and enter on the command line:

$python hello.py

To run hello.py. You can see the Python's subsequent output

Hello World! Script

We can also change the Python program hello.py into an executable script that can be executed directly:

#! / usr/bin/env pythonprint ('Hello Worldwide')

You need to modify the permissions of the above program to be executable:

Chmod 755 hello.py

Then on the command line, enter

. / hello.py

You can run it directly.

Thank you for your reading, the above is "how to use Python to achieve Hello World" content, after the study of this article, I believe you have a deeper understanding of how to use Python to achieve Hello World this problem, the specific use of the situation also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Commands programs input learning output content that is text editors scripts runs keywords functions functions characters strings screens commonly used ideas Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia vpn Microsoft Apple MySQL