Python中文
首页
教程
问答
标签
搜索
登录
注册
如何使用pythonsubprocess.check_输出带根/sud
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我正在编写一个Python脚本,它将在Raspberry上运行,它将从传感器读取温度并记录到Thingspeak。我用bash脚本来处理这个问题,但是不能用Python来实现,因为这样更容易操作和检查读取值。传感器读数是用一个名为loldht的库完成的。我试着这样做:</p> <pre><code>from subprocess import STDOUT, check_output output = check_output("/home/pi/bin/lol_dht22/loldht", timeout=10) </code></pre> <p>问题是我必须用sudo运行库才能访问pin。我将以cron的身份运行脚本。可以用sudo运行这个吗?在</p> <p>或者我可以创建一个执行“sudo loldht”的bash脚本,然后从python运行bash脚本吗?在</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>可以使用cron运行sudo命令。只需使用sudo crontab-e设置cron,它应该可以正常工作。在</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
如何将Python中的列表复制到给定的目标中?
1 回答
如何将python中的列表插入SQL表
8 回答
如何将python中的列表转换为numpy数组以放入十位
8 回答
如何将python中的列表输入javascript?
8 回答
如何将python中的列表返回给dag?
1 回答
如何将Python中的列表项重新排列成成对的元组/列表?
9 回答
如何将Python中的初始化对象序列化为XML?
10 回答
如何将python中的十进制字符串转换为数字?
7 回答
如何将Python中的原始输入文本转换为Tkinter中的标签?
5 回答
如何将python中的反斜杠命令转换为在Linux上运行
1 回答
如何将python中的命令行参数转换为字典?
10 回答
如何将python中的图像值传递到kivy中的kv文件?
8 回答
如何将Python中的图像数组(枕头对象)上传到Google云
6 回答
如何将Python中的图像编码为Base64?
6 回答
如何将python中的图像调整为灰度低分辨率,如MNIST时尚数据?
7 回答
如何将python中的多个html输出保存到单个文件(或多个)中?
10 回答
如何将Python中的多个ifelse语句重构为一个函数?
3 回答
如何将Python中的多处理与Django结合使用,从xml文件创建数千个模型实例?
7 回答
如何将python中的多级API响应转换为dataframe
8 回答
如何将python中的多线程编程模型转换为异步/等待模型?
1 回答