In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article shows you how to carry out the simple implementation of the Python Helloworld program, the content is concise and easy to understand, it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
For a friend who has learned a programming language, he is sure to remember the word Helloworld deeply. Almost in the early days of learning the language, we all use this simple Mini Program to have an in-depth understanding of the programming language. So today I will introduce the implementation of Python Helloworld program for you.
Before starting the creation of the Python Helloworld program, you first need to create a new file c:\ test.py
Write something like this in this file.
Str = "hello world"
Print str
In this way, we have written a script.
Execute such a statement in the command line of python
Execfile ("c:\\ test.py")
So, you can see the result. Ha
Now we have one more requirement, that is, we need to use a separate file to write some configuration parameters.
For example, now we build such a file Global.py in the root directory of C disk.
Write some sentences in it: str1 = "hello world2"
So how do we use them: change the test.py to something like this.
Import sys sys.path.append (.') Import Global str = "hello world" print str print Global.str1
Now we can execute such a statement in python command line
Execfile ("c:\\ test.py") trouble shooting:
You may encounter such a situation during the implementation of a Python Helloworld program
Import Global ImportError: No module named Global
This is because he did not find the corresponding Global file under C:
Let's make sure first.
Check the current working directory
Import os os.getcwd ()
At this time, it is possible to display the installation directory of the python
Of course I can't find Global.py.
What we need to do is os.chdir ("c:\")
Then we execute os.getcwd (), and see if the working directory has changed.
Now let's do it again: execfile ("c:\\ test.py")
OK.
Of course, we can also do this:
C:\ > python test.py hello world hello world2 the above content is how to implement the Python Helloworld program simply. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.