TabError: inconsistent use of tabs and spaces in indentation问题解决 (ubuntu16.04+python3.6 )

代码

for image_file in os.listdir(test_path):
print('image_file =',image_file)

        try:
            image_type = imghdr.what(os.path.join(test_path,image_file))
            if not image_type:
                continue
        except IsADirectoryError:
            continue
报错:

# python test_yolo.py model_data/yolo.h5

File "test_yolo.py",line 118
print('image_file =',image_file)
^

TabError: inconsistent use of tabs and spaces in indentation

原因:

ubuntu(linux)下,缩进用空格(Space)键,如果用Tab键,系统报错。windows下不存在该问题。

print('image_file =',image_file) 改行缩进使用了Tab键。

解决办法:

用Tab的位置使用空格(Space)键替换。

相关文章

目录前言一、创建Hadoop用户二、更新apt和安装Vim编辑器三、...
原文连接:https://www.cnblogs.com/yasmi/p/5192694.html ...
电脑重启后,打开VirtualBox,发现一直用的虚拟机莫名的消失...
参见:https://blog.csdn.net/weixin_38883338/article/deta...
Ubuntu 18.04 LTS 已切换到 Netplan 来配置网络接口。Netpla...
介绍每个 Web 服务都可以通过特定的 URL 在 Internet 上访问...