在Python中设置硬件时钟? [英] Set the hardware clock in Python?

查看:101
本文介绍了在Python中设置硬件时钟?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在嵌入式Linux系统上使用Python设置硬件时钟?

How do I set the hardware clock with Python on embedded Linux systems?

推荐答案

除了进行os.system()调用外,可能没有其他简便的方法.

Probably no easy way other than doing an os.system() call.

import os
os.system('hwclock --set %s' % date_str)

或使用日期"命令

import os
os.system('date -s %s' % date_str)

或者如果您想做一些c编码,请用swig包裹系统调用...但是我认为这比它的价值还要大.

or if you are dying to do some c coding, wrapping the system calls with swig... but I think that would be more work than its worth.

这篇关于在Python中设置硬件时钟?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆