技能 n8n-code-python
📦

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.

支援: Claude Codex Code(CC)
🥉 74 青銅
1

下載技能 ZIP

2

在 Claude 中上傳

前往 設定 → 功能 → 技能 → 上傳技能

3

開啟並開始使用

測試它

正在使用「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}}]

安全審計

安全
v1 • 2/25/2026

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.

1
已掃描檔案
751
分析行數
0
發現項
1
審計總數
未發現安全問題
審計者: claude

品質評分

38
架構
100
可維護性
87
內容
50
社群
100
安全
91
規範符合性

你能建構什麼

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.

試試這些提示

Basic Python Code Node Setup
Help me create a basic Python Code node in n8n that processes incoming items and adds a timestamp field to each item.
Data Aggregation with Python
Write Python code for n8n that calculates the sum and average of an 'amount' field across all input items.
Regex Pattern Extraction
Create Python code that extracts email addresses from text fields using regex in an n8n Code node.
Webhook Data Processing with Error Handling
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']

常見問題

Can I use external Python libraries like requests or pandas in n8n Code nodes?
No, n8n Python Code nodes only support the standard library. For HTTP requests, use an HTTP Request node before the Code node or switch to JavaScript which has $helpers.httpRequest().
What is the correct return format for Python Code nodes?
Always return a list of dictionaries where each dictionary has a 'json' key. Example: return [{"json": {"field": "value"}}]
Why is my webhook data returning KeyError when I access _json['email']?
Webhook data is nested under the 'body' key. Access it as _json['body']['email'] or use _json.get('body', {}).get('email') for safe access.
Should I use Python or JavaScript for n8n Code nodes?
JavaScript is recommended for 95% of use cases because it has full access to n8n helper functions and Luxon date library. Use Python only when you need specific standard library functions.
How do I access data from previous nodes in Python Code nodes?
Use _input.all() to get all items, _input.first() for the first item, or _node['NodeName']['json'] to reference a specific node's output.
What Python modules are available in n8n Code nodes?
Standard library modules including json, datetime, re, base64, hashlib, urllib.parse, math, random, and statistics are available.

開發者詳情

檔案結構

📄 SKILL.md