# Python小工具 **Repository Path**: runawayfantasy/python-gadgets ## Basic Information - **Project Name**: Python小工具 - **Description**: Python实现的小工具 1.批量添加windows用户 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2021-12-27 - **Last Updated**: 2023-09-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Python小工具 ## 1.批量创建Windows用户 使用**pyinstaller**将python程序打包成exe程序: `pyinstaller -F -i m1.ico addUser.py` | -h,--help | 查看该模块的帮助信息 | | --------------------------- | ------------------------------------------------------------ | | -F,-onefile | 产生单个的可执行文件 | | -D,--onedir | 产生一个目录(包含多个文件)作为可执行程序 | | -a,--ascii | 不包含 Unicode 字符集支持 | | -d,--debug | 产生 debug 版本的可执行文件 | | -w,--windowed,--noconsolc | 指定程序运行时不显示命令行窗口(仅对 Windows 有效) | | -c,--nowindowed,--console | 指定使用命令行窗口运行程序(仅对 Windows 有效) | | -o DIR,--out=DIR | 指定 spec 文件的生成目录。如果没有指定,则默认使用当前目录来生成 spec 文件 | | -p DIR,--path=DIR | 设置 Python 导入模块的路径(和设置 PYTHONPATH 环境变量的作用相似)。也可使用路径分隔符(Windows 使用分号,Linux 使用冒号)来分隔多个路径 | | -n NAME,--name=NAME | 指定项目(产生的 spec)名字。如果省略该选项,那么第一个脚本的主文件名将作为 spec 的名字 | ### 实现原理: ```python terminal = subprocess.run( "net user " + prefix_value + connector_value + username + " " + password_value + " /add", shell=True, encoding='utf-8') ``` python的**subprocess**模块可以执行shell命令 `add user username password /add` python可视化界面:**tkinter** > 注:所有模块均为python自带(python3.9) ## 2.数据库转Excel表格