为什么报错没有文件

shenmeyebudong129 2017-11-30 10:39:58
# -*- 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
...全文
169 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
shenmeyebudong129 2017-12-01
  • 打赏
  • 举报
回复
引用 1 楼 oyljerry 的回复:
文件路径最好拼接成完整路径。不然相对路径文件不好找
你好 具体应该怎么做呢?? 我不太理解 谢谢
oyljerry 2017-11-30
  • 打赏
  • 举报
回复
文件路径最好拼接成完整路径。不然相对路径文件不好找

37,743

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • WuKongSecurity@BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧