简体   繁体   English

制作另一个脚本的Python脚本

[英]Python Script to Make Another Script

I have looked around for a while now and am still unable to find an answer to a method of doing this. 我现在已经看了一会儿,仍然无法找到这样做的方法的答案。 I have made a few scripts to solve equations and now am looking for a way to write a script that will allow input of steps into an equation,number and name of variables etc. My idea is to make a script that will take all of these inputs and then write another script that will ask for the numbers in an equation and solve the equation. 我已经制作了一些脚本来解决方程式,现在我正在寻找一种编写脚本的方法,该脚本允许将步骤输入到方程式,变量的数量和名称等等。我的想法是创建一个将采用所有这些的脚本输入然后写另一个脚本,询问方程中的数字并求解方程式。 Any ideas of how to write the first script so that it can create a second? 有关如何编写第一个脚本以便创建第二个脚本的任何想法?

Also I forgot to mention that I want the newer script to be saved for later use/execution. 另外我忘了提到我希望保存更新的脚本以供以后使用/执行。

Instead of writing a script that creates another script, a better way to solve the problem would be to write functions. 而不是编写创建另一个脚本的脚本,解决问题的更好方法是编写函数。

For example, the first function would read the names of variables, etc. and return these data as a dictionary. 例如,第一个函数将读取变量的名称等,并将这些数据作为字典返回。

Next, you would pass this dictionary into the second function, which, depending on the information stored in the dictionary, would read the remaining inputs and return another dictionary with the inputs. 接下来,您将把这个字典传递给第二个函数,根据存储在字典中的信息,它将读取剩余的输入并返回带有输入的另一个字典。

Then, you could use the data from the returned dictionary to solve the equation. 然后,您可以使用返回字典中的数据来求解方程式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM