-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patha.py
More file actions
58 lines (53 loc) · 1.2 KB
/
Copy patha.py
File metadata and controls
58 lines (53 loc) · 1.2 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
import sys
import time
import datetime
import os
#
# f = open('test.text', 'a+')
# def write_data(i):
# time.sleep(1)
# s = str(datetime.datetime.now())
# f.write(str(i) + ',' + s)
# f.write('\n')
# pass
#
# def get_num(fi):
# s = fi.readlines()
# if len(s) != 0:
# l = s[-1]
# if l == '\n':
# i = 0
# else:
# i = int(l[0])
# return i
#
#
# i = get_num(f) + 1
# while True:
# write_data(i)
# i += 1
# pass
# --------------------------------------------------->
path = '/home/linux/python/mydir/'
f = open('all.text', 'a')
rootdir = os.listdir(path)
def get_dir_file(onedir):
return os.listdir(path + onedir)
pass
def get_file_content(filename):
fileobj = open(filename, 'r')
return fileobj.readlines()
pass
def write_content(filename):
fr = open(filename, 'r')
f.writelines(fr.readlines())
pass
for chiderdir in rootdir:
if os.path.isfile(path + chiderdir):
print "==========="
else:
print "---------"
filename = get_dir_file(chiderdir)
for chiderfile in filename:
filepath = path + chiderdir + '/' + chiderfile
write_content(filepath)