我正在尝试将秒转换为毫秒(或微秒)而不除以 1,000 或 1,000,000。我这样做的原因是因为我不想显示小数点。有没有一种方法可以显示没有小数点且不除以 1,000 或 1,000,000 的毫秒或微秒?
这是我的方法执行时间的代码:
from random import randint
list = [1]*1000
for i in range (1, 1000):
list[i] = randint(1,100)
def insertion(list):
for index in range(1,len(list)):
value = list[index]
i = index - 1
while i>=0 and (value < list[i]):
list[i+1] = list[i]
list[i] = value
i = i - 1
def test():
start = time.clock()
insertion(list)
elapsed = (time.clock() - start)
print "Time taken for insertion = ", elapsed
if __name__ == '__main__':
import time
test()