File tree 2 files changed +55
-0
lines changed
2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change
1
+ .
2
+ ├── anaconda-ks.cfg
3
+ ├── a.txt
4
+ ├── cxcc
5
+ │ ├── a.py
6
+ │ ├── a.txt
7
+ │ ├── ez_setup.py
8
+ │ ├── pip-9.0.1
9
+ │ ├── pip-9.0.1.tar.gz
10
+ │ ├── Python-2.7
11
+ │ └── Python-2.7.tgz
12
+ ├── devstack
13
+ │ └── local.yaml
14
+ ├── install.log
15
+ └── install.log.syslog
16
+
17
+ 5 directories, 9 files
Original file line number Diff line number Diff line change
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # 文件操作
4
+ print '------------- 文件操作 -------------'
5
+
6
+ type_1 = '├── '
7
+ type_2 = '│ ├── '
8
+ type_3 = '│ └── '
9
+ type_4 = '├── '
10
+ type_5 = '└── '
11
+
12
+ L = []
13
+ aFile = open ('../a.txt' )
14
+
15
+ line = aFile .readline ().strip ('\n ' )
16
+ while line != '' :
17
+ print line
18
+ t = line .split (type_1 )
19
+ if len (t ) >= 2 :
20
+ L .append (t [- 1 ])
21
+ elif len (line .split (type_2 )) >= 2 :
22
+ L .append (line .split (type_2 )[- 1 ])
23
+ elif len (line .split (type_3 )) >= 2 :
24
+ L .append (line .split (type_3 )[- 1 ])
25
+ elif len (line .split (type_4 )) >= 2 :
26
+ L .append (line .split (type_4 )[- 1 ])
27
+ elif len (line .split (type_5 )) >= 2 :
28
+ L .append (line .split (type_5 )[- 1 ])
29
+ line = aFile .readline ().strip ('\n ' )
30
+
31
+ print L
32
+
33
+ # print aFile.readlines()
34
+
35
+ # print '├──'
36
+ # print '─'
37
+ # a = '│ └── local.yaml'
38
+ # print a.split('├── ')
You can’t perform that action at this time.
0 commit comments