0

(私は初心者です) Python は通常、インデントを使用してコード行のネスト レベルを指定します。これを行う他の方法はありますか?

4

3 に答える 3

11

いいえ、Python 開発者はこれに非常に抵抗しています。Python の基になっているコア基盤の 1 つを変更することになるからです。ただ試してみてくださいfrom __future__ import braces

>>> from __future__ import braces
SyntaxError: not a chance (<pyshell#30>, line 1)

確かに、「チャンスではない」:-)

于 2013-06-21T15:36:19.773 に答える
1

The core design philosophy behind Python is human readability; indentation is used to specify code blocks because visually, this is significantly cleaner than the use of braces.

For more info, see PEP 20 - The Zen of Python.

于 2013-06-21T15:40:49.213 に答える