In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the knowledge of "how to run Python scripts in Windows and trigger the corresponding functions regularly". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Catalogue
Environment introduction
Run the Python script: .bat file
For example:
Regularly trigger .bat file in Windows (English version system)
Environment introduction
System environment: Windows 10
Python version: Python 3.5
Prerequisite package: none
Run the Python script: .bat file
In Windows, .bat files are batch files, much like .sh (shell) files in Linux.
If we want to run a Python script in Windows, we can first go to the directory where the python file is located through CMD, and then run it.
But this is troublesome, every time you have to open CMD, enter the folder, and run the file.
Therefore, in order not to re-enter every time, it is recommended that the code be written in a txt file. After writing, just change the suffix of the txt file to .bat, and then double-click to run it.
For example:
Suppose we have a script called "test.py" in the "C:\ Users\ Desktop" directory.
We want to have something like exe, and every time we double hit, we will automatically get a result.
So, we can take the following steps:
1. In any folder, create a notepad file (suffix .txt) and open the file
two。 Enter the following in the folder: (the first sentence is used to switch the folder path, and the second sentence is used to run the python script)
Cd C:\ Users\ Desktoppython test.py
3. Save exit
4. Change the suffix of notepad from .txt to .bat
At this time, double-click the .bat file, you will find that you ran the result of python ~
Regularly trigger .bat file in Windows (English version system)
Sorry personal system is only available in English and no screenshots are available in Chinese. There is no way to restrict the computer.
In Windows, follow these steps to trigger the job:
1. Right-click my computer
two。 Select "Manage" and the following window pops up
3. Select System Tools-Task Scheduler-Task Scheduler Library in turn
4. Click "Create Basic Task" in the Action column on the right to create a basic task
5. Fill in the name and description of the task and write it down casually. Click next
6. Select the frequency and specific time of the task
7. Select "Start a program"
8. Click "Browse..." and select the .bat file we want to run
Then the next step is Finish.
That's all for "how to run a Python script in Windows and trigger the corresponding function regularly". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.