Python 学习笔记 031

 周末练习作业  邮箱处理 02 

续前节


10.根据目录存在性作出判断  通过加Not实现  14:08

10.1 目录存在 忽略并继续  

10.2  目录不存在 创建并继续    1508

Debug  Debug报错

1. NotADirectoryError: [WinError 267] 目录名称无效。: 'D:\\python-project\\newdir\\kaifang.txt'

试了很久才发现是目录问题,应该写到文件夹未知  不应该包含文件名

2.TabError: inconsistent use of tabs and spaces in indentation

缩进错误(至今不知道啥原因,以前的else这么用 没问题啊) 删除之else后解决

3.AttributeError: module 'ntpath' has no attribute 'exist' 

刚开始以为是ntpath版本的问题 后来才发现是exist少打了个s (汗)

4.IndexError: list index out of range   官方报错(代码问题)  后续解决(教程未解决)详见032

5.TypeError: '<' not supported between instances of 'str' and 'int'

少使用个Len函数 直接将字符串与数字比较  

6.IndexError: list index out of range  手动解决 详见032



未完待续

你可能感兴趣的:(Python 学习笔记 031)