start:raspberry:nodered:python
Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
start:raspberry:nodered:python [2025/01/29 11:00] – créée admin | start:raspberry:nodered:python [2025/02/03 17:08] (Version actuelle) – [Utilisation de python dans node-red] admin | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
======== Installation python dans node-red ======== | ======== Installation python dans node-red ======== | ||
+ | |||
+ | [[https:// | ||
====installation de python-shell==== | ====installation de python-shell==== | ||
- | sudo npm install node-red-contrib-pythonshell | + | sudo npm install node-red-contrib-python-shell |
- | + | == Usage == | |
- | | + | |
+ | Exécution d'un script Python depuis node-red. L' | ||
+ | |||
+ | L' | ||
+ | |||
+ | ==Exemple de script Python == | ||
+ | |||
+ | Et voici le contenu du script python : | ||
+ | |||
+ | <code python exemple002.py> | ||
+ | |||
+ | import sys | ||
+ | print "Got arguments: ", sys.argv | ||
+ | </ | ||
+ | ==== Installation d'un noeud Python-Fonction ==== | ||
+ | sudo npm install node-red-contrib-python-function-ps --save | ||
+ | ==Usage== | ||
+ | |||
+ | Comme le nœud de fonction, écrivez du code Python au lieu du code JavaScript et exécutez-le. | ||
+ | |||
+ | <code python exemple001.py> | ||
+ | # user code here. | ||
+ | |||
+ | a = 1234 | ||
+ | |||
+ | node.globals[" | ||
+ | del node.globals[" | ||
+ | |||
+ | write_output(" | ||
+ | msg[" | ||
+ | |||
+ | return msg | ||
+ | </ | ||
+ | |||
+ | ===== Utilisation de python dans node-red ===== | ||
+ | |||
+ | [[https:// | ||
+ | [[https:// |
/home/chanteri/www/fablab37110/data/attic/start/raspberry/nodered/python.1738144843.txt.gz · Dernière modification : 2025/01/29 11:00 de admin