Hello everyone , I'm an old watch ~
A previous article use Python Set up a fund inquiry robot , It can also expand !, need Python The environment is 3.7 And above , For the first time in Linux Installation on Python( The previous ones were all built-in Python3.6.8), Record .
It is recommended to download locally ( Download faster ), Then through the pagoda , Upload the file to the server .
First of all, the following URL of the local browser service , Find what you want to download python edition , Click to download .
https://www.python.org/downloads/source/
Be careful , On the left is the stable version , On the right is the pre release version , What I choose here is Python3.7.9, Click on Download XZ compressed source tarball.
We will download the good Python The source compressed package is uploaded to the specified folder of the server through the pagoda ( I am here root/Project One is created under the folder soft Folder ), After uploading , Right click inside the pagoda to decompress .
If you don't know how to install and use the pagoda panel , You can read the articles in the past :Linux Inside “ pagoda ”, The real pagoda ! Detailed tutorial
Next we can still use the pagoda , Click... On the pagoda panel terminal , Enter the following commands in sequence .
The final installation directory I set here is /usr/local/python3.7
cd /root/soft/Python-3.7.9 ./configure --prefix=/usr/local/python3.7 make make install
After successful installation , The installation directory will also be printed out , This prompt indicates that this directory has not been added to the environment variable , We can add , Or directly configure the soft link .
The first use of nano Open profile ~/.bashrc, Add a line at the end export PATH="/usr/local/python3.7/bin:$PATH", preservation sign out , Finally, run the configuration file .
nano ~/.bashrc # After adding environment variables , Run the configuration file source ~/.bashrc
But even so , Still have to set up a soft link , Or use python3.7 Get into Python Program .
What we use here is ln Instructions , take python3.7 Executable software links directly to /usr/bin Medium python3,pip3.7 link to /usr/bin Medium pip3, So we can use it directly python3 pip3 It corresponds directly to 3.7 Version of the .
ln -sf /usr/local/python3.7/bin/python3.7 /usr/bin/python3 ln -sf /usr/local/python3.7/bin/pip3.7 /usr/bin/pip3
Set it up , We can type in python3 --version See if the link is successful .
Create a .pip Folder , For storage pip The configuration file .
mkdir .pip && cd .pip
We still use nano Directive to edit the file ,
nano pip.conf
Copy the following to it , Then press ctrl+o Save the file , Press again ctrl+x Exit the edit mode .
[global] index-url = https://mirrors.aliyun.com/pypi/simple [install] trusted-host = mirrors.aliyun.com
Except alicloud image , You can also choose other image sources ,
University of science and technology of China https://pypi.mirrors.ustc.edu.cn/simple douban http://pypi.douban.com/simple Tsinghua University https://pypi.tuna.tsinghua.edu.cn/simple University of science and technology of China http://pypi.mirrors.ustc.edu.cn/simple
The first thing to install is pipenv, Easy to create 、 Manage virtual environments , Install requests Crawl data , Install another pandas Processing data .
pip3 install pipenv rquests pandas
Let's talk about the train of thought : From numbers 、 Case letters 、 Select the number of characters of specified length randomly in special characters , Then form a string .
We can input by ourselves , You can also use ready-made bags , such as string, yes Python A built-in package for , You can quickly get all kinds of characters .
import string string.printable
It's also Python Built in package random, There are mainly built-in :randint、random、randrange、choice、choices Such as function .
import random
random.choices('abc', k=2)
import string
import random
while True:
try:
password_len = int(input(' Please enter the password length ( It's just numbers ):'))
password = ''.join(random.choices(string.printable.strip(), k=password_len))
print(f' Your new password is :{password}, Please keep it ~')
except Exception as e:
print(f'【 Error 】 See if there is an input error , It may be that non digital content has been entered , error message :{e}')
print('*** If you want to finish, enter 0 Well !!!***')
print('*** Press enter to continue generating a new password ***')
flag = input(' Continue to generate new password :')
if flag == '0':
break
print('******************************************')
There's time later , I'll optimize it , Hey, hey, hey ~