为什么报错没有文件
# -*- coding:utf-8 -*-
import os
import shutil
def getFileName(path):
f_list = os.listdir(path)
L = []
for i in f_list:
if os.path.splitext(i)[1] == '.txt':
L.append(i)
for j in range(len(L)):
clip1 = float(L[j][53:60])
clip2 = float(L[j][61:68])
if (clip1>2.5 and clip1<53.33) and (clip2>73.33 and clip2<135.05):
# os.mkdir('example1')
oldname = L[j]
newname = u'F:\chuli\kong'
print(L[j])
print(newname)
shutil.copy(oldname,newname)
if __name__ == "__main__":
path = 'F:\chuli\ForL2'
getFileName(path)
print("结束")
C:\Python3.6\python.exe F:/chuli/test.py
Traceback (most recent call last):
GOSATTFTS2016010104590070260 2016-01-01 04-59-49.832 24.8052#121.135_band1.txt
F:\chuli\kong
File "F:/chuli/test.py", line 25, in <module>
getFileName(path)
File "F:/chuli/test.py", line 21, in getFileName
shutil.copy(oldname,newname)
File "C:\Python3.6\lib\shutil.py", line 241, in copy
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "C:\Python3.6\lib\shutil.py", line 120, in copyfile
with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: 'GOSATTFTS2016010104590070260 2016-01-01 04-59-49.832 24.8052#121.135_band1.txt'
进程已结束,退出代码1