通过环境变量获取用户路径

This commit is contained in:
shuaikangzhou 2023-12-01 22:44:56 +08:00
parent c713c591bd
commit f492beaf44

View File

@ -22,9 +22,9 @@ def get_abs_path(path):
def wx_path(): def wx_path():
## 获取当前用户名 ## 获取当前用户名
users = os.path.expandvars('$HOMEPATH') user_home = os.environ.get("USERPROFILE")
## 找到3ebffe94.ini配置文件 ## 找到3ebffe94.ini配置文件
f = open(r'C:' + users + '\\AppData\\Roaming\\Tencent\\WeChat\\All Users\\config\\3ebffe94.ini', encoding='utf-8') f = open(user_home + '\\AppData\\Roaming\\Tencent\\WeChat\\All Users\\config\\3ebffe94.ini', encoding='utf-8')
txt = f.read() txt = f.read()
f.close() f.close()
# 打开Windows注册表 # 打开Windows注册表