程序问答   发布时间:2022-06-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了将值发送到 python 脚本然后运行大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决将值发送到 python 脚本然后运行?

开发过程中遇到将值发送到 python 脚本然后运行的问题如何解决?下面主要结合日常开发的经验,给出你关于将值发送到 python 脚本然后运行的解决方法建议,希望对你解决将值发送到 python 脚本然后运行有所启发或帮助;

抱歉,各位,我是 php 开发人员,而不是 Python 开发人员。这对某人来说可能是非常基本的。我想导入一个 python 脚本,但向它发送一个值 (ID) 以便它运行。我有一个“父”页面,在其他脚本之后导入一个页面,并在它们返回预期值时运行它们。使用 python 3

On parent script...

import script1 << give ID
script 1 get the ID and run a query and return values

impot script2 << send ID
script 2 get the ID and run a query and return v

解决方法

通常的pythonic方式是导入所需的方法并在脚本中执行这些方法。请参下面的例子。

script1

def example_method():
   return 1

script2

def example_method_2():
   return 1

你的脚本

from script1 import example_method
from script2 import example_method_2

result1 = example_method()
result2 = example_method_2()

大佬总结

以上是大佬教程为你收集整理的将值发送到 python 脚本然后运行全部内容,希望文章能够帮你解决将值发送到 python 脚本然后运行所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: