我有一个代码,我希望分割成多个文件。在 matlab 中,人们可以简单地调用一个 .m文件,只要它没有被定义为任何特定的东西,它就会像被调用代码的一部分那样运行。例子(已编辑) :
Test.m (matlab)
function [] = test()
... some code using variables ...
test2
Test2.m (matlab)
... some more code using same variables ...
调用 test将运行 test2中的代码和 test2中的代码。
Python 是否有类似的方法,将 ... some more code ...放入一个外部文件中,这样就可以像在调用它的文件中一样简单地读取它?