27 Star 5 Fork 54

qpy-doc-center / teedoc_with_qpydoc

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
example.md 901 Bytes
一键复制 编辑 原始数据 按行查看 历史

example - Execute Python Scripts

This document introduces how to execute Python scripts on the command line or in the code.

example.exec

example.exec(filePath)

Executes the specified Python script file.

Parameter

  • filePath - String type. Absolute path for Python script file execution.

Example

# Assuming there is a test.py file

def myprint():
    count = 10
    while count > 0:
        count -= 1
        print('##### test #####')

myprint()

#Uploads test.py to the module, enters the command line and executes the following codes
>>> uos.listdir('/usr/')
['apn_cfg.json', 'test.py']
>>> import example
>>> example.exec('/usr/test.py')
# Execution results are as follows

##### test #####
##### test #####
##### test #####
##### test #####
##### test #####
##### test #####
##### test #####
##### test #####
##### test #####
##### test #####
1
https://gitee.com/qpy-doc-center/teedoc_with_qpydoc.git
git@gitee.com:qpy-doc-center/teedoc_with_qpydoc.git
qpy-doc-center
teedoc_with_qpydoc
teedoc_with_qpydoc
main

搜索帮助