Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
level3-lesson13-diy1
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c1e9d2d0
authored
Oct 02, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
92449b0c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
4 deletions
diy1.py
diy1.py
View file @
c1e9d2d0
'''
计算把0插入list列表1000次所用的时间
time:返回的是一个时间戳,单位是格林威治
'''
#导入时间模块
import
time
#创建变量计算开始时间
start_time
=
time
.
time
()
print
(
"开始时间为:"
,
start_time
)
#创建列表
list1
=
[]
for
a
in
range
(
0
,
1000
):
for
b
in
range
(
0
,
1000
):
list1
.
insert
(
0
,
0
)
\ No newline at end of file
#开始循环把0加入到list1列表里面
for
a
in
range
(
0
,
1000
):
for
b
in
range
(
0
,
100
):
#使用inser方法,插入数据
list1
.
insert
(
0
,
0
)
#创建变量接收结束时间
end_start
=
time
.
time
()
print
(
"结束时间为:"
,
end_start
)
#创建变量计算所用时间
sj
=
end_start
-
start_time
#输出
print
(
"把0插入列表所用时间为"
,
sj
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment