

open建立管道,管道中的值决定我们得读、写、追加



相对路径:在同一级别得情况下可以往下查询

- import os
-
- src = r'E:\aaa\1'
- target = r'E:\aaa\2'
-
- def copy(src, target):
- if os.path.isdir(src) and os.path.isdir(target):
- listdir = os.listdir(src)
- for file in listdir:
- src_file_path = os.path.join(src, file)
- with open(src_file_path, 'r') as rStream:
- read = rStream.read()
-
- target_file_path = os.path.join(target, file)
- with open(target_file_path, 'w') as wStream:
- wStream.write(read)
- else:
- print("复制完成")
-
-
- copy(src, target)