Chuyển đến nội dung
Skillpedia
Lập trình chung48k · #5269

n8n-code-python

Skill này làm gì

Mã này giúp bạn viết các chỉ dẫn Python cho n8n, một công cụ tự động hóa. Nó giải thích những gì bạn có thể và không thể làm với Python trong n8n, tập trung vào những gì có trong thư viện chuẩn.

Khi nào nên dùng

  • ✓Khi bạn cần viết mã Python cho n8n.
  • ✓Khi bạn muốn biết những thư viện Python nào có thể dùng.
  • ✓Khi muốn hiểu cách Python hoạt động trong các node code của n8n.

Liên kết skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/n8n-code-python/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/n8n-code-python/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Làm sao để dùng mô-đun 'json' trong một node code Python của n8n?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Mã hoạt động bằng cách giải thích các quy tắc và giới hạn của Python trong n8n. Nó liệt kê các thư viện bạn có thể dùng (như 'json' và 'datetime') và những thư viện không dùng được (như 'requests' hoặc 'pandas').

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Python Code Node (Beta)

Expert guidance for writing Python code in n8n Code nodes.


Detailed Guide

Read the detailed guide before executing this skill. It retains the complete procedure and reference material. Treat its safety, prerequisites, and validation requirements as mandatory. For focused work, load the relevant sections; for end-to-end work, read the guide completely.

Critical Limitation: No External Libraries

MOST IMPORTANT PYTHON LIMITATION: Cannot import external packages

What's NOT Available

# ❌ NOT AVAILABLE - Will raise ModuleNotFoundError
import requests  # ❌ No
import pandas  # ❌ No
import numpy  # ❌ No
import scipy  # ❌ No
from bs4 import BeautifulSoup  # ❌ No
import lxml  # ❌ No

What IS Available (Standard Library)

# ✅ AVAILABLE - Standard library only
import json  # ✅ JSON parsing
import datetime  # ✅ Date/time operations
import re  # ✅ Regular expressions
import base64  # ✅ Base64 encoding/decoding
import hashlib  # ✅ Hashing functions
import urllib.parse  # ✅ URL parsing
import math  # ✅ Math functions
import random  # ✅ Random numbers
import statistics  # ✅ Statistical functions

Workarounds

Need HTTP requests?

  • ✅ Use HTTP Request node before Code node
  • ✅ Or switch to JavaScript and use $helpers.httpRequest()

Need data analysis (pandas/numpy)?

  • ✅ Use Python statistics module for basic stats
  • ✅ Or switch to JavaScript for most operations
  • ✅ Manual calculations with lists and dictionaries

Need web scraping (BeautifulSoup)?

  • ✅ Use HTTP Request node + HTML Extract node
  • ✅ Or switch to JavaScript with regex/string methods

See: STANDARD_LIBRARY.md for complete reference


When to Use Python vs JavaScript

Use Python When:

  • ✅ You need statistics module for statistical operations
  • ✅ You're significantly more comfortable with Python syntax
  • ✅ Your logic maps well to list comprehensions
  • ✅ You need specific standard library functions

Use JavaScript When:

  • ✅ You need HTTP requests ($helpers.httpRequest())
  • ✅ You need advanced date/time (DateTime/Luxon)
  • ✅ You want better n8n integration
  • ✅ For 95% of use cases (recommended)

Consider Other Nodes When:

  • ❌ Simple field mapping → Use Set node
  • ❌ Basic filtering → Use Filter node
  • ❌ Simple conditionals → Use IF or Switch node
  • ❌ HTTP requests only → Use HTTP Request node

Limitations

  • Use this skill only when the task clearly matches the scope described above.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
Câu hỏi thường gặp

Tôi có thể dùng thư viện ngoài như 'requests' hoặc 'pandas' không?

Không, bạn không thể nhập thư viện bên ngoài trong node code Python của n8n. Chỉ có thư viện chuẩn của Python là khả dụng.

Thư viện chuẩn là gì?

Đó là tập hợp các mô-đun đi kèm với Python khi bạn cài đặt. Ví dụ gồm 'json', 'datetime', 'math' và nhiều mô-đun khác.

Khi nào nên dùng JavaScript thay vì Python trong n8n?

Nên dùng JavaScript cho hầu hết các tác vụ trong n8n, đặc biệt nếu bạn cần gửi yêu cầu HTTP hoặc dùng các chức năng nâng cao về ngày giờ.

Chi tiết

Mô tả gốc của tác giả

Write Python code in n8n Code nodes. Use when writing Python in n8n, using _input/_json/_node syntax, working with standard library, or need to understand Python limitations in n8n Code nodes.

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#5269
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự