【发布时间】:2014-02-11 06:03:17
【问题描述】:
我的代码中的特定 for 循环出现问题。我得到的错误是“TypeError: coercing to Unicode: need string or buffer, list found
我的代码是:
current_dir = os. getcwd()
target_dire = [os.listdir(current_dir)]
for dirs in target_dirs:
if is.path.isdir(dirs):
print dirs[0]
else:
pass
提前致谢
【问题讨论】:
-
抱歉我的手机弄乱了代码缩进
-
哪一行出错
-
if 语句行。
-
打印目录或查看目录类型
标签: python-2.7 for-loop