鱼C论坛

 找回密码
 立即注册
查看: 2778|回复: 4

[已解决]帮我看一道作业题

[复制链接]
发表于 2016-10-30 18:07:19 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
file:///C:/Users/MBENBEN/Desktop/QQ%E6%88%AA%E5%9B%BE20161030180342.png

为什么会报错,作业30-3
代码:
  1. def find (path,f):
  2.     os.chdir(path)
  3.     all_file = os.listdir(os.curdir)
  4.     for each_file in all_file:
  5.         if ('.mp4' in os.path.splitext(each_file)[1])or('.avi' in os.splitext(each_file)[1]):
  6.             f.writelines (path+'\\'+each_file)
  7.         if os.path.isdir(each_file):
  8.             find(each_file)
  9.             os.chdir(os.pardir)
  10.     f.close()


  11. import os
  12. import os.path
  13. start = input('请输入待查找的初始目录:')
  14. f=open(start+'\\videoList.txt','w')
  15. find (start,f)
复制代码
最佳答案
2016-10-30 19:03:43
改为
if ('.mp4' in os.path.splitext(each_file)[1])or('.avi' in os.path.splitext(each_file)[1]):
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2016-10-30 18:07:59 | 显示全部楼层
为什么不能上传本地图片。。。
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2016-10-30 18:08:45 | 显示全部楼层
Traceback (most recent call last):
  File "G:/Python作业/30-3.py", line 17, in <module>
    find (start,f)
  File "G:/Python作业/30-3.py", line 5, in find
    if ('.mp4' in os.path.splitext(each_file)[1])or('.avi' in os.splitext(each_file)[1]):
AttributeError: module 'os' has no attribute 'splitext'



这个是报错的信息
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2016-10-30 19:03:43 | 显示全部楼层    本楼为最佳答案   
改为
if ('.mp4' in os.path.splitext(each_file)[1])or('.avi' in os.path.splitext(each_file)[1]):
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2016-10-30 21:05:07 | 显示全部楼层
无符号整形 发表于 2016-10-30 19:03
改为
if ('.mp4' in os.path.splitext(each_file)[1])or('.avi' in os.path.splitext(each_file)[1]):

阿西吧,果然要很细心才对呀。  哈哈 很开心 又没有鱼B了。。小甲鱼老师,双十一U盘有没有什么优惠或者活动呀。@小甲鱼
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2026-2-23 15:11

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表