[Share Experiences] python用管理员权限运行终端命令
Tofloor
poster avatar
尘世滴
deepin
2022-06-06 03:09
Author
import pexpect

ch = pexpect.spawn('sudo su', encoding='utf-8')
ch.expect('密码')
ch.sendline('')  # 这里填sudo密码
ch.expect('验证成功')
ch.sendline('') # 这里填终端命令

不能开启人脸识别,有bug

Reply Favorite View the author
All Replies
来自Ubuntu的某位用户
deepin
2022-06-06 03:34
#1

谢谢你的分享,原来我像让Python以管理员权限执行命令我直接以管理员权限运行的脚本

例如

sudo python3 / *** / ***.py

Reply View the author
神末shenmo
deepin
Spark-App
Q&A Team
2022-06-06 06:55
#2

也可以看看我写的这个咯

https://gitee.com/deepin-community-store/spark-store/blob/master/tool/password-check/ss-certificate-passwd

Reply View the author