time.clock_settime()
“时间”模块的方法用于设置指定时钟clk_id的时间(以秒为单位)。本质上,clk_id是一个整数值,代表时钟的id。
用法: time.clock_settime(clk_id, seconds)
参数:
clk_id:clk_id常数或代表时钟clk_id的整数值。
返回类型:此方法不返回任何值。
代码:用于time.clock_settime()
方法
# Python program to explain time.clock_settime() method
# importing time module
import time
# clk_id for System-wide real-time clock
clk_id = time.CLOCK_REALTIME
# Get the current value of
# system-wide real-time clock (in seconds)
# using time.clock_gettime() method
t = time.clock_gettime(clk_id)
print("Current value of system-wide real-time clock:% d seconds" % t)
# Set the new value of
# time (in seconds) for
# System-wide real-time clock
# using time.clock_settime() method
seconds = 10000000
time.clock_settime(clk_id, seconds)
print("\nTime modified")
# Get the modified value of
# system-wide real-time clock (in seconds)
# using time.clock_gettime() method
t = time.clock_gettime(clk_id)
print("\nCurrent value of system-wide real-time clock:% d seconds" % t)
输出:
Current value of system-wide real-time clock:1568589568 seconds Time modified Current value of system-wide real-time clock:10000000 seconds
参考: https://docs.python.org/3/library/time.html#time.clock_settime
相关用法
- Python next()用法及代码示例
- Python os.dup()用法及代码示例
- Python set()用法及代码示例
- Python Decimal max()用法及代码示例
- Python PIL ImageOps.fit()用法及代码示例
- Python os.rmdir()用法及代码示例
- Python sympy.det()用法及代码示例
- Python Decimal min()用法及代码示例
- Python os.readlink()用法及代码示例
- Python os.writev()用法及代码示例
- Python os.readv()用法及代码示例
- Python PIL RankFilter()用法及代码示例
- Python os.rename()用法及代码示例
- Python os.sendfile()用法及代码示例
注:本文由纯净天空筛选整理自ihritik大神的英文原创作品 Python | time.clock_settime() method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。