python中缩进在程序中_有没有办法将Python代码中的缩进转换为大括号?
Python支持用于定義代碼塊的大括號(hào),并且它還支持使用“開(kāi)始”和“結(jié)束”標(biāo)記。
請(qǐng)看這些代碼示例:class MyClass(object): #{
def myfunction(self, arg1, arg2): #{
for i in range(arg1): #{
print i
#}
#}
#}
還有一個(gè)帶有bash樣式的例子:fi = endclass = enddef = endclass = done = None
class MyClass(object):
def myfunction(self, arg1, arg2):
for i in range(arg1): #do
if i > 5: #then
print i
fi
done
enddef
endclass
這方面最好的一點(diǎn)是,你可以忘記在其中放置一個(gè)近距括號(hào),而它仍然是有效的python!class MyClass(object): #{
def myfunction(self, arg1, arg2): #{
for i in range(arg1): #{
print i
# whoops, forgot to close that bracket!
#}
#}
總結(jié)
以上是生活随笔為你收集整理的python中缩进在程序中_有没有办法将Python代码中的缩进转换为大括号?的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: android monkey压力测试,A
- 下一篇: 用python开启相机_如何用Pytho