如何从另一个python文件运行函数

问题描述

我有一个.py:

   Class boxfinitestatemachine(models):
   ..... 
       @transistion...
       def hello(self):
           Print happy
       ....
       @transostion..
       def bye(self):
           Print sad
        ....

通常情况下,运行方式为:在外壳窗口中按F5并输入以下命令:

        >>>State= boxfinitestatemachine()      #input
        >>> State.hello() #input
        >>> happy         #output
        >>> State.bye()  # input
        >>> Sad           #output

现在我有了另一个文件b.py,其中包含FOR循环功能如下:

         For I in range 2:

现在我需要,如果I == 0,则必须执行state.hello并打印出来。

类似地,对于I == 1,应执行state.bye并打印Sad。

如何执行此要求。任何帮助。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)