test__str__

简介

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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# coding='utf-8'

iter_obj = iter([1,2,3])

def _next(iter_obj):
try:
return next(iter_obj)
except StopIteration:
return None

print(iter([1,2,3]))

# print(next(iter_obj))

# print(_next(iter_obj))

# print(_next(iter_obj))

# print(_next(iter_obj))

for i in iter_obj: #for 循环比next方法好,不容易报错
print(i)

def make_iter():
for i in range(10):
yield i
iter_obj = make_iter()
print(type(iter_obj))

for i in iter_obj:
print(i)
print('_______')
for i in iter_obj:
print(i)

iter_obj = (i for i in range(10))
for i in iter_obj:
print(i)
print("=======")

for i in iter_obj:
print(i)