问答详情
源自:2-5 封装多格式的文本信息抽取工具

代码编写跟着写完,报这个错误

Traceback (most recent call last):

  File "D:/pycode/data_preprocessing/extractTxt.py", line 66, in <module>

    files2txt(filepath1)

  File "D:/pycode/data_preprocessing/extractTxt.py", line 26, in files2txt

    new2txtpath = os.path.join(savepath, new_name)

  File "C:\Program Files\Python38\lib\ntpath.py", line 109, in join

    genericpath._check_arg_types('join', path, *paths)

  File "C:\Program Files\Python38\lib\genericpath.py", line 152, in _check_arg_types

    raise TypeError('%s() argument must be str or bytes, not %r' %

TypeError: join() argument must be str or bytes, not 'NoneType'


提问者:慕沐9044854 2020-10-27 17:01

个回答

  • lgsp_lucifer1225
    2021-02-12 20:32:35

    我觉得你是切割文件名和后缀的时候,splitext写成split导致的。

  • 慕沐9044854
    2020-10-28 08:40:00

    elif fnmatch.fnmatch(filename, '*.docx'):

    写成

    if fnmatch.fnmatch(filename, '*.docx'):

    ,导致new_name返回的是NoneType