Module: A module is actually a Python file
There are three modules
1. Standard modules, standard packages
# These modules that come with python,
import string, random, datetime, os, json that can be used directly by import
2. Third-party modules, some modules written by others, you can only install them Use
1. Fool-style: pip install pymysql
(1) What to do if there is no pip command:
1. Click python console in pycharm
2. Find the python installation directory
3. Then add the scripts directory under the installation directory to the environment variable.
But ps: add
(2) Unknown or unsupported command 'install' to the environment variable in the PATH. How to solve this question 1.
Open C:\strawberry\perl\bin\
2. Change all pips in this directory to other ones Name, this has no effect on others
2. Manual installation
(1), installation package at the end of whl
pip install redis-2.10.6-py2.py3-none-any.whl
(2), installation package at the end of .tar.gz
1. Unzip the compressed package
2. Enter the unzipped folder
3. Run python setup.py install on the command line
3. Python file written by yourself
Random module:
import random,string print (string.printable) #represents numbers , letters, special characters print (random.randint(1,10)) #random integers print (round(random.uniform(1,99),2)) # Random decimals print (random.choice([1,2,3,4,5])) #Only one element can be taken at random print (random.sample(string.printable,5)) #Randomly take N elements and return is list #shuffle pickts =[ ' A ' , ' B ' , " C " , " D " ] random.shuffle(pickts) #Only pass list print (pickts) #Results :