window.onload的使用情况

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>window.onload</title>
<style>
#box {
width: 100px;
height: 100px;
margin: 20px auto;
background: #ccc;
}
</style>
</head>
<body>
<div id = 'box'></div>
</body>
</html>
<script>
var box = document.getElementById('box')
box.onclick = function () {
alert(123)
}
</script>

阅读更多

HTML+CSS

HTML+CSS

阅读更多

HTML-02:HTML基础,标签

一、图片 img

阅读更多

HTML-01:HTML基础概念

一、HTML是什么

阅读更多

自定义迭代器Range

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class Range:
def __init__(self, start, end=None, step=1):
if end is not None:
self.start = start
self.end = end
else:
self.end = start
self.start = 0
self.step = step

def __iter__(self):
return self

def __next__(self):
if self.start < self.end:
current = self.start
self.start += self.step
return current
else:
raise StopIteration()


xx = Range(100000000)
ll = range(100000000)
xx.__sizeof__() # 32 内存占用 byte 字节
ll.__sizeof__() # 48
xx # <__main__.Range at 0x28295befb70>
ll # range(0, 100000000)

阅读更多

随机数迭代器

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 定义⼀个随机数迭代器, 随机范围为 [1, 50], 最⼤迭代次数 10
import random


class RandomIter:
def __init__(self, start, end, times):
self.start = start
self.end = end
self.max_times = times
self.count = 0

def __iter__(self):
return self

def __next__(self):
self.count += 1
if self.count <= self.max_times:
return random.randint(self.start, self.end)
else:
raise StopIteration()

r = RandomIter(1,50,10)
lst = []
for i in r :
lst.append(i)

print(lst)

阅读更多

Drupal翻译

Drupal翻译方法

阅读更多