python中一般使用几个空格表示缩进_为什么大家都说python中用tab缩进的都是弱鸡,而只有用四个空格缩进的才是高手?...

本文介绍了Python编程中的代码风格指南PEP8,建议使用空格进行缩进,以保持代码一致性。尽管Python3不允许混合使用tab和空格,但在Python2中,若代码已经混用,应将它们转换为全使用空格。PEP8还推荐使用-t或-tt选项来检查代码中的非法混合缩进,以确保代码质量。
摘要由CSDN通过智能技术生成

参考PEP8,Spaces are the preferred indentation method.

Tabs should be used solely to remain consistent with code that is already indented with tabs.

Python 3 disallows mixing the use of tabs and spaces for indentation.

Python 2 code indented with a mixture of tabs and spaces should be converted to using spaces exclusively.

When invoking the Python 2 command line interpreter with the -t option, it issues warnings about code that illegally mixes tabs and spaces. When using -tt these warnings become errors. These options are highly recommended!

大概就是说,最好用空格。

源码用了tab,为了保持缩进一致再用tab。

Python3 不可混用,2可以混用。

但是PEP8参考一下就好了,tab在许多IDE是可以转为空格的。PEP 8 -- Style Guide for Python Code​www.python.orgv2-ff06c339780f23112c1cbbbb284158ff_ipico.jpg

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值