在Python中......如何从.txt文件中提取名称和ext

时间:2017-04-06 14:11:38

标签: python

我的档案就像这样。

  label0/index.jpeg 0

  label1/index.jpeg 1

我的代码是

 def add_ext_name(cls, path, ext_name): 
    name, ext = os.path.splitext(os.path.basename(path))
    added = os.path.join(os.path.dirname(path), name + ext_name + ext)
    return added

错误是

 def basename(p):
   """Returns the final component of a pathname"""
     p = os.fspath(p)
     sep = _get_sep(p)
     i = p.rfind(sep) + 1

TypeError: expected str, bytes or os.PathLike object, not ImageProperty

我在哪里弄错了?

0 个答案:

没有答案