Skip to content

Commit c8109da

Browse files
author
DESKTOP-DH18EE5\Tao
committed
init
0 parents  commit c8109da

12 files changed

Lines changed: 228 additions & 0 deletions

one/.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"python.linting.pylintEnabled": false
3+
}
273 Bytes
Binary file not shown.
128 KB
Binary file not shown.

one/date.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#%%
2+
from datetime import datetime, timedelta
3+
4+
A=datetime.now().strftime('%Y/%m/%d%H%M')
5+
print(A)
6+
#2017/11/012253
7+
#%%
8+
A=datetime.strptime("201701012330", "%Y%m%d%H%M%S")
9+
print(A.strftime('%Y/%m/%d %H%M'))
10+
#2017/01/01 2303
11+
12+
#%%
13+
A = A - timedelta(days =1)
14+
print((datetime.now() - timedelta(days = 1)).strftime('%Y/%m/%d %H%M'))
15+
#2017/10/31 2253

one/dict.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
sArray = {
2+
'day':'Wednessday',
3+
'animal': 'Cat',
4+
'id': 2
5+
}
6+
7+
print(sArray['day'])
8+
#Wednessday
9+
10+
del sArray['id']
11+
print(sArray)
12+
#{'day': 'Wednessday', 'animal': 'Cat'}
13+
14+
sArray['id2'] = '00551'
15+
print(sArray)
16+
#{'day': 'Wednessday', 'animal': 'Cat', 'id2': '00551'}
17+
18+
sArray.update({ 'id': '004156', 'newKey': 'value' })
19+
print(sArray)
20+
#{'day': 'Wednessday', 'animal': 'Cat', 'id2': '00551', 'id': '004156', 'newKey': 'value'}
21+
22+
for eachKey in sArray:
23+
print(sArray[eachKey])
24+
#Wednessday
25+
#Cat
26+
#004156

one/function.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
def testData(var1=None):
3+
return {
4+
'name': 'Clefable',
5+
'skill': 'singing'
6+
}

one/list.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
2+
3+
A = ['Monday', 'Tuesday', 'Wednessday', 'Thursday', 'Friday']
4+
B = ['Fish', 'Dog', 'Cat', 'Sheep', 'Fish']
5+
6+
#-------- concat ----------
7+
8+
A+B
9+
print(A+B)
10+
# ['Monday', 'Tuesday', 'Wednessday', 'Thursday', 'Friday', 'Fish', 'Dog', 'Cat', 'Sheep', 'Fish']
11+
12+
#-------- pop, append ----------
13+
14+
A.pop(1)
15+
print(A)
16+
# ['Monday', 'Wednessday', 'Thursday', 'Friday']
17+
18+
A.append('WOW')
19+
print(A)
20+
# ['Monday', 'Wednessday', 'Thursday', 'Friday', 'WOW']
21+
22+
#-------- filter, map, sorted ----
23+
24+
sArray = [
25+
{
26+
'day':'Monday',
27+
'animal': 'Fish',
28+
'id': 0
29+
},
30+
{
31+
'day':'Tuesday',
32+
'animal': 'Dog',
33+
'id': 1
34+
},
35+
{
36+
'day':'Wednessday',
37+
'animal': 'Cat',
38+
'id': 2
39+
}
40+
]
41+
42+
demo = list( filter( lambda x: x['animal'] == 'Fish' , sArray) )
43+
print(demo)
44+
# [{'day': 'Monday', 'animal': 'Fish', 'id': 0}]
45+
46+
demo = list( map( lambda x: x['day'], sArray) )
47+
print(demo)
48+
# ['Monday', 'Tuesday', 'Wednessday']
49+
50+
demo = sorted( sArray, key = lambda x: x['id'], reverse=True )
51+
print(demo)
52+
# [
53+
# {'day': 'Wednessday', 'animal': 'Cat', 'id': 2},
54+
# {'day': 'Tuesday', 'animal': 'Dog', 'id': 1},
55+
# {'day': 'Monday', 'animal': 'Fish', 'id': 0}
56+
# ]
57+
58+
# -------- Quick filter and map
59+
60+
demo = [ x for x in sArray if x['animal'] == 'Fish' ]
61+
print(demo)
62+
63+
demo = [ x['day'] for x in sArray ]
64+
print(demo)
65+
66+
67+
# -------- Loop --------
68+
for eachItem in sArray:
69+
if eachItem['day'] == 'Monday':
70+
print(eachItem['animal'] + 'Boom!!')
71+
72+
73+
74+
75+
76+
77+
78+
79+
80+

one/oracle/__init__.py

Whitespace-only changes.
136 Bytes
Binary file not shown.
1.81 KB
Binary file not shown.

0 commit comments

Comments
 (0)