Set the hardware clock in Python?

后端 未结 4 1098
星月不相逢
星月不相逢 2020-12-17 23:32

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

4条回答
  •  别那么骄傲
    2020-12-18 00:04

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

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

    or using the 'date' command

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

    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.

提交回复
热议问题