Import OS
# Print (OS.GETCWD ()) #获取当前目录, Absolute path
# Print (Os.chdir ('.. /')) #更改当前目录,.. /means to return to the top level directory
# Print (OS.GETCWD ())
# print (os.curdir) #当前目录, relative path
# print (os.pardir) #当前目录, relative path
# Print (Os.mkdir (' test0117 ')) #创建文件夹
# Print (Os.rmdir (' test0117 ')) #删除文件夹, only empty folders can be deleted
# Print (Os.remove (' 11.png ')) #删除文件, cannot delete folder
# Print (Os.listdir (' c:/')) #列出一个目录下的所有文件
# os.rename (' test0117 ', ' MPP ') #重命名
# Print (Os.stat (' file_d ')) #获取文件信息
# print (__file__) #_file_文件的绝对路径
# Print (Os.path.abspath (__file__)) #获取文件的绝对路径
# Print (Os.path.split (' E:\testpy\python-mpp\day5\ exercises \ Common module OS and sys.py '))
#分割路径和文件名
# Print (Os.path.dirname (' e:/testpy/python-mpp/day5/exercise/Common module OS and sys.py '))
#获取父目录
# Print (Os.path.basename (' e:/testpy/python-mpp/day5/exercise/Common module OS and sys.py '))
# Gets the last level, if the file displays the filename, if the directory displays the directory name
# Print (os.path.exists (' 11 common modules OS and sys.py ')) # Directory/file exists
# Print (Os.path.isfile (' Common module OS and sys.py ')) #判断是否是一个文件
# Print (Os.path.isdir (' Common module OS and sys.py ')) #是否是一个文件夹
# name = ' A.sql '
# Print (Os.path.join ("E", name)) #拼接成一个路径
# print (OS.SEP) #当前操作系统的路径分隔符
# print (OS.LINESEP) # line break for the current operating system
# print (OS.PATHSEP) # The delimiter for each path in the environment variables of the current system, Linux is:, Windows is;
# print (Os.environ) # Environment variables for the current system
# print (os.name) # current system name
# Os.system (' dir ') #用来执行操作系统命令, can only execute, get no results
# res = Os.popen (' ipconfig ') #用来执行操作系统命令, and gets the result returned. Read
# Print (Res.read ())
Import Sys
# print (Sys.path) #环境变量
# print (sys.platform) #看当前系统是什么
Print (sys.version) #看python的版本
Print (Sys.exit (' program exit '))
Quit (' program quit ') #退出程序
Import Random
Import string
# Print (Random.randint (1,199)) #1_199随机取一个整数
# print (string.digits) #所有的数字0-9
# print (string.ascii_lowercase) #所有的小写字母
# print (string.ascii_uppercase) #所有的大写字母
# print (string.ascii_letters) #所有的小写字母 + ALL caps
# print (string.punctuation) #所有的特殊字符
# MPP = Random.choice ([' iphone ', ' Xiaomi ', ' Huawei ']) #随机取一个元素
# mpp=[' iphone ', ' Xiaomi ', ' Huawei '
# res = random.sample (mpp,2) #随机取N个元素
# Print (RES)
# res = random.uniform (1,9) #取随机小数
# Print (RES)
# Print (round (res,3)) #保留几位小数
s = [' iphone ', ' Xiaomi ', ' Huawei ', ' MPP ']
Random.shuffle (s) #洗牌, scramble order, only list
Print (s)
Python's OS, sys, and random modules