import os
stack = [os.getcwd()]
while len(stack) > 0:
cwd = stack.pop()
file = [i for i in cwd if os.path.isfile() and os.path.isfile(i) and i.split('.')[-1] == 'py']
dirs = [os.path.join(cwd, i) for i in cwd if os.path.isdir(i)]
stack.extend(dirs)
for py in file:
with open(py) as f:
txt = ''.join(f.readlines())
txt = txt.replace('\t', ' ')
with open(py, 'w') as f:
f.write(txt)
没测试过逃。。
形成良好的编码规范是好事,我现在就喜欢Python的缩进,
为什么都用空格?用TAB的我是异类吗?
Atom编辑器,默认Tab自动换成空格的。
python编码规范中提倡空格缩进
1、使用空格缩进
2、编辑器选好用的
3、见到有用tab缩进的同事劝他用空格
4、见到空格和tab混用的同事劝你砍死他
EditorConfig
http://ju.outofmemory.cn/entry/104488
绝大多数编辑器都能设置tab换为X个空格
用空格缩进