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 中上傳
前往 設定 → 功能 → 技能 → 上傳技能
開啟並開始使用
測試它
正在使用「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']