网站建设 平易,wordpress 关于我们,网页制作网页,用服务器建立网站吗主要使用两个函数#xff0c;一个是run函数#xff0c;一个runResults函数#xff0c;两者区别如下#xff1a; 两个函数均接受一个字符串作为输入#xff0c;默认输出类型也为字符串。字符串表示要执行的Python代码。
pyCom.run(import plotter);Attempt a…主要使用两个函数一个是run函数一个runResults函数两者区别如下 两个函数均接受一个字符串作为输入默认输出类型也为字符串。字符串表示要执行的Python代码。
pyCom.run(import plotter);Attempt attemptpyCom.run(import plotter);
traceln(Import was successful?%s,attempt.isSuccessful());数据类型的分配
pyCom.run(value3.14); #分配浮点型数据
pyCom.run(text hello); #分配字符型数据在使用runResults返回时默认是字符型。
String feedbackStr pyCom.runResults(35).getFeedback(); #分配浮点型数据
int feedbackInt pyCom.run(35).getFeedback(int.class); #分配整数型数据
# 或者如下形式
int feedbackInt pyCom.runResults(int.class,35);转为JSON格式数据。
String json {\nVehicles\:5,\ncapacity\:120};
ManufacturingCenter mfc pyCom.fromAgentJson(json,ManufacturingCenter.class);本地Python文件导入时将Python文件放置在同模型文件相同的文件夹下。 另外Python代码可以以字符串形式传入Pycom.run的参数中执行Python程序。 调用参数时可以使用占位符得到参数。