In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Today, I will talk to you about the Python scheme implemented in the Python dictionary. Many people may not know much about it. In order to let you know more, Xiaobian summarizes the following contents for you. I hope you can gain something according to this article.
Executable Python
This section applies only to Linux/Unix users, although Windows users may also be curious about the *** line of the program. First we need to give the program executable permission via the chmod command, and then run the program.
$ chmod a+x helloworld.py $ ./ helloworld.py Hello World
The chmod command is used to change the mode of a file, giving all users on the system permission to execute the source file. We can then execute the program directly by specifying the location of the source file. We use./ To indicate that the program is located in the current directory. To make things more interesting, you can change your filename to just helloworld and run./ helloworld。This way, the program still works because the system knows it must run the program with the interpreter specified in the *** line of the source file.
Once you know the exact location of the program, you can run it now-but what if you want your program to run from every location? That way, you can save your program in one of the directories in the PATH environment variable. Every time you run any program, the system looks for directories listed in the PATH environment variable. and run that program. You can make your program available anywhere by simply copying the source file to one of the directories listed in PATH.
$ echo $PATH
/opt/mono/bin/:/usr/local/bin:/usr/bin:/bin:/usr/X11R6
/bin:/home/swaroop/bin
$ cp helloworld.py /home/swaroop/bin/helloworld
$ helloworld
Hello World
We can display PATH variables with echo, prefixing the variable name with $to indicate to the shell that we need the value of the variable. We see that/home/swaroop/bin is one of the directories in the PATH variable. swaroop is the username used in my system. Usually, there will be a similar directory in your system. You can also add directories of your choice to PATH variables--this can be done by running PATH=$PATH:/home/swaroop/mydir, where
"/home/swaroop/mydir"
is the directory I want to add to PATH.
This method is useful when you want to run your program anytime, anywhere. It's like creating your own commands, like cd or any other Linux terminal or DOS prompt command. Tip: For Python, program, script, or software all mean the same thing.
After reading the above, do you have any further understanding of how Python's schemes are implemented in Python dictionaries? If you still want to know more knowledge or related content, please pay attention to the industry information channel, thank you for your support.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.