-
Notifications
You must be signed in to change notification settings - Fork 14
03002_刘洪义_期中作业第一次提交 #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
The head ref may contain hidden characters: "03002\u5218\u6D2A\u4E49"
Conversation
| allFiles.append(filename) | ||
| return (allPath,allFiles) | ||
|
|
||
| def setNewPath(original_path,target_path):#根绝原始文件目录创建新路径下的文件夹目录 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doc string 应该放在函数体内,像这样:
def setNewPath(original_path,target_path):
"""根绝原始文件目录创建新路径下的文件夹目录"""There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
其他的函数一样
| #print(target_name) | ||
| if not os.path.exists(target_name): | ||
| os.makedirs(target_name) | ||
| def creatfolder(target_path):#根据收到的maya文件名称创建集号,镜头号等.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create_folders这个名字会不会更好点?
| if not os.path.exists(temp_ep_path): | ||
| #print(temp_ep_path) | ||
| os.makedirs(temp_ep_path) | ||
| for i in cam: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嵌套循环里,循环变量都是i是不行的
| if not os.path.exists(temp_cam_path): | ||
| os.makedirs(temp_cam_path) | ||
|
|
||
| def getNum(original_path):#根据给到的maya文件名称获得集号镜头号等.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
函数名PEP8风格要求——get_num
| cam = [] | ||
| joinpath =[] | ||
| '''allFiles = ["ep05_sc001_cam001_v001", "ep06_sc001_cam002a_v004", "ep06_sc003_cam001b_v002", "ep04_sc003_cam009H_v002", | ||
| "ep06_sc004_cam001a-v001"]''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这种注释不能留在代码里
| cam.append(num[0][1]+"\\"+num[0][2]) | ||
| joinpath.append(num[0][0]+"\\"+num[0][1]+"\\"+num[0][2]) | ||
| #print(num[0][0]) | ||
| return(ep,sc,cam,joinpath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
四个同样元素数量的列表,这个结构不够合理。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return 一个由列表组成的元组,这种方式不合理。
| temp_cam_path = os.path.join(temp_ep_path,i) | ||
| if not os.path.exists(temp_cam_path): | ||
| os.makedirs(temp_cam_path) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
函数之间空两行,参考PEP8
| count = 0 | ||
| Projectinformation = os.path.join(projectpath, 'Projectinformation.txt') | ||
| for root , dirs, files in os.walk(original_path): | ||
| for name in files: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嵌套循环略丑陋
| else: | ||
| shutil.copy(base_name, target_name) | ||
| os.rename(target_name,target_final_name) | ||
| else:#如果复制文件夹内有子文件夹,则把子目录文件复制到目标路径根目录下 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
表扬一下: 在这种复杂的逻辑中,写了注释,这是很好的。
03002 刘洪义 期中作业第一次提交