(python website) 网頁从其他 python 脚本获取输出, 遇 model not found error

根据文章 https://stackoverflow.com/questions/6086047/get-output-of-python-script-from-within-python-script

我创建了 在线网页 (.html) 运行其他 .py 脚本,也就是 import 自己的脚本,结果遇 model not found error

逻辑上似乎 python 代码没问题,可能是设置错误或其他我自己没有想到的问题

  • printbob.py
import sys

def main(args):
    for arg in args:
        print(arg)

if __name__ == '__main__':
    main(sys.argv)
  • test_0109_003.html
<html>
    <head>
      <link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css" />
      <script defer src="https://pyscript.net/latest/pyscript.js">script>
    head>
  <body>
    <b><p>title test 1.10-test_get_ print  p>b>
    <br>


  
    <py-script>
      import printbob

      printbob.main('arg1 arg2 arg3 arg4'.split(' '))
      
    py-script>
  body>
html>
  • (pic 01) 网站显示结果

    enter image description here


  • (pic 02)确认有把 .py 和 .html 脚本放在 WinSCP,在线主机系统,但 import model not found

    enter image description here

那么该如何解决这个问题

<html>
  <head>
    <link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css" />
    <script defer src="https://pyscript.net/latest/pyscript.js"></script>
  </head>
  <body>
    <py-script src="1.py">
   
    </py-script>
    
  </body>
</html>

1.py

args='arg1 arg2 arg3 arg4'.split(' ')
for arg in args:
        print(arg)
 

试试看把脚本引入进来,参考https://docs.pyscript.net/latest/reference/elements/py-script.html