
回复
这个仓库是为了能够在鸿蒙设备上使用 Python 进行应用程序开发而创建。
1. 使用Python开发鸿蒙设备程序(0-初体验)
这个仓库的 Baseline 是 MicroPython v1.13,在 MicroPython 的基础上进行了必要的剪裁以满足 HOS 上的应用开发需求。
#include "dtpython.h"
extern const char* c_test_py; // test.py
extern const char* c_another_py; // another.py
static void DTPython_Demo_Entry(void)
{
printf("[DTPython_Demo] DTPython_Demo_Entry()\n");
DTPython_Init(); // 初始化Python环境
DTPython_RunCode("print(\'Python Code Begin\')"); // 执行Python语句:print('Python Code Begin')
DTPython_RunCode("s = \'HOS Device Development\'"); // 执行Python语句:s = 'HOS Device Development'
DTPython_RunCode("print(s)"); // 执行Python语句:print(s)
DTPython_RunCode(c_test_py); // 模拟执行Python文件:DTPython_RunFile("test.py");
DTPython_RunCode(c_another_py); // 模拟执行Python文件:DTPython_RunFile("another.py");
DTPython_RunCode("print(\'Python Code End\')"); // 执行Python语句:print('Python Code End')
DTPython_Deinit(); // 清理Python环境
}