本文介绍了定义循环语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 限时删除!! 我希望能够定义一个循环语句 (永远不要明白为什么)这样我就可以写一些像 循环10: do_something 而不是 for i in range(10): do_something 可能吗?如果是这样,怎么样? 谢谢, Alan Isaac 解决方案 创建一个新的语句是不可能的,套件是 和缩进规则而不会破解翻译或者 求助于替代字节码编译器,例如pyc。 创建一个名为function的_function_很简单,就像Jonathan的 答案所示。 Georg 是的。通过为您的编程实现编译器或解释器 语言。或者是将您的语言转换为Python的预处理器,或者其他适合的中间语言的预处理器。或者是程序员,将你的伪代码和一些咖啡转换为所需的算法:-) - $ b $bRenéPijlman I would like to be able to define a loop statement(nevermind why) so that I can write something likeloop 10:do_somethinginstead offor i in range(10):do_somethingPossible? If so, how?Thanks,Alan Isaac 解决方案It''s not possible to create a new statement, with suiteand indentation rules without hacking the interpreter orresorting to alternative bytecode compilers such as "pyc".Creating a _function_ named "loop" is easy as Jonathan''sanswer shows.GeorgYes. By implementing a compiler or an interpreter for your programminglanguage. Or a preprocessor that converts your language to Python, or someother suitable intermediate language. Or a programmer, that converts yourpseudocode and some coffee to the desired algorithm :-)--René Pijlman 这篇关于定义循环语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的..
09-08 21:01