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.
Baixar o ZIP da skill
Upload no Claude
Vá em Configurações → Capacidades → Skills → Upload skill
Ative e comece a usar
Testar
A utilizar "n8n-code-python". Transform all items to add a processed flag and uppercase the name field
Resultado esperado:
- Python Code node returns: [{"json": {"id": 1, "name": "ALICE", "processed": true}}, {"json": {"id": 2, "name": "BOB", "processed": true}}]
A utilizar "n8n-code-python". Calculate total and count from items with amount fields
Resultado esperado:
- Python Code node returns: [{"json": {"total": 150, "count": 5, "average": 30}}]
Auditoria de Segurança
SeguroStatic 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.
Pontuação de qualidade
O Que Você Pode Construir
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.
Tente Estes Prompts
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.
Melhores Práticas
- 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
Evitar
- 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']