Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement Hello World with Python

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report