-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathshengchengqi.py
More file actions
61 lines (50 loc) · 1.17 KB
/
shengchengqi.py
File metadata and controls
61 lines (50 loc) · 1.17 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2020 wmsj100 <wmsj100@hotmail.com>
#
# Distributed under terms of the MIT license.
"""
"""
class Flatten:
def __init__(self):
pass
def flatten(self, list):
for sublist in list:
for element in sublist:
yield element
#list1 = [[1,2],[3,4],[5]]
#
#def flatten(list):
# for sublist in list:
# for element in sublist:
# yield element
#
#
#for num in flatten(list1):
# print(num)
class Digui:
def __init__(self):
pass
def flatten(self, listVal):
try:
for sublist in listVal:
for element in self.flatten(sublist):
yield element
except TypeError:
yield listVal
class Digui1:
def __init__(self):
pass
def flatten(self, listVal):
try:
try:
listVal + ''
except TypeError: pass
else: raise TypeError
for sublist in listVal:
for element in self.flatten(sublist):
yield element
except TypeError:
yield listVal