n8n-code-python
Write Python Code in n8n Code Nodes
Create Python-powered automation workflows in n8n using standard library functions. Learn the correct syntax, data access patterns, and limitations for Python Code nodes.
تنزيل ZIP المهارة
رفع في Claude
اذهب إلى Settings → Capabilities → Skills → Upload skill
فعّل وابدأ الاستخدام
اختبرها
استخدام "n8n-code-python". Transform all items to add a processed flag and uppercase the name field
النتيجة المتوقعة:
- Python Code node returns: [{"json": {"id": 1, "name": "ALICE", "processed": true}}, {"json": {"id": 2, "name": "BOB", "processed": true}}]
استخدام "n8n-code-python". Calculate total and count from items with amount fields
النتيجة المتوقعة:
- Python Code node returns: [{"json": {"total": 150, "count": 5, "average": 30}}]
التدقيق الأمني
آمنStatic analysis flagged 124 patterns but all are false positives. The SKILL.md file is documentation only, not executable code. Markdown code fences (```python) were incorrectly detected as shell backticks. URL references are documentation links. hashlib references show available standard library modules. No actual security risks exist.
درجة الجودة
ماذا يمكنك بناءه
Data Transformation in Automation Workflows
Transform and aggregate data from previous workflow nodes using Python list comprehensions and built-in functions.
Statistical Analysis of Workflow Data
Calculate mean, median, and standard deviation from workflow data using Python statistics module.
Data Validation and Cleaning
Validate incoming data with regex patterns and safe dictionary access using .get() methods.
جرّب هذه الموجهات
Help me create a basic Python Code node in n8n that processes incoming items and adds a timestamp field to each item.
Write Python code for n8n that calculates the sum and average of an 'amount' field across all input items.
Create Python code that extracts email addresses from text fields using regex in an n8n Code node.
Write robust Python code for n8n that safely accesses webhook body data with proper error handling for missing fields.
أفضل الممارسات
- Always use .get() for dictionary access to avoid KeyError on missing fields
- Return data in the required format: list of dictionaries with 'json' key
- Consider JavaScript first - use Python only when standard library functions are needed
- Use list comprehensions for efficient filtering and transformation of items
تجنب
- Attempting to import external libraries like requests or pandas - these will fail with ModuleNotFoundError
- Returning a dictionary without wrapping in a list - n8n requires [{"json": ...}] format
- Accessing webhook data directly via _json['field'] instead of _json['body']['field']