os模块
import os cmd_res1 = os.system("dir") print(cmd_res1) # 执行命令 不保存结果 cmd_res2 = os.popen("dir").read() print("---->\n\n",cmd_res2) os.mkdir("new_dir")
sys
import sys print(sys.path) print(sys.argv) # C:\\Users\\python\\AppData\\Local\\Programs\\Python\\Python36-32\\lib 系统库存放 # C:\\Users\\python\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages 第三方库存放
getpass 模块
#!/usr/bin/env python # -*- coding: utf-8 -*- import getpass # 自建登录脚本可被别人调用,在同目录下先,不然就在环境变量下,如site-packages _username = "kim" _password = "abc123" username = input("username:") password = getpass.getpass("password:") if _username == username and _password ==password : print("Welcome") else: print("fuck off")