【文件属性】:
文件名称:python-switch:将开关块添加到Python
文件大小:9KB
文件格式:ZIP
更新时间:2021-02-17 12:17:06
python language python3 switch Python
开关郎
将开关块添加到Python语言。
此模块在不更改语言的情况下为Python添加了显式的开关功能。 它基于定义执行块的标准方法: with语句。
例子
from switchlang import switch
def main ():
num = 7
val = input ( "Enter a character, a, b, c or any other: " )
with switch ( val ) as s :
s . case ( 'a' , process_a )
s . case ( 'b' , lambda : process_with_data ( val , num , 'other values still' ))
s . default ( process_any )
d
【文件预览】:
python-switch-master
----requirements-dev.txt(15B)
----switchlang()
--------__switchlang_impl.py(5KB)
--------__init__.py(387B)
----tests()
--------test_core.py(8KB)
----LICENSE(1KB)
----setup.py(1KB)
----.gitignore(1KB)
----README.md(6KB)