docx
यह क्या करती है
यह स्किल AI एजेंट को Microsoft Word दस्तावेज़ों के साथ काम करने देती है। यह उन लोगों के लिए है जिन्हें रिपोर्ट, पत्र या memo Word फ़ाइल में चाहिए, या मौजूदा Word फ़ाइलें पढ़नी और संपादित करनी हैं।
कब इस्तेमाल करें
- ✓जब आपको .docx फ़ाइल के रूप में Word रिपोर्ट, पत्र या memo बनवाना है।
- ✓जब आप मौजूदा Word फ़ाइल से टेक्स्ट या टेबल निकालना चाहते हैं।
- ✓जब आपको Word दस्तावेज़ में tracked changes या comments जोड़ने हैं।
Skill का लिंक
https://github.com/HKUDS/DeepTutor/blob/main/deeptutor/skills/builtin/docx/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“इन नोट्स को headings, एक टेबल और पेज नंबर के साथ Word रिपोर्ट में बदलिए।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
एजेंट ज़्यादातर कामों के लिए python-docx लाइब्रेरी इस्तेमाल करता है, और tracked changes तथा comments जैसे उन्नत मामलों के लिए कच्चा Word XML लिखता है। वह मूल फ़ाइल को बदलने के बजाय नई आउटपुट फ़ाइल सेव करता है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
DOCX (Microsoft Word)
A .docx is a ZIP of XML parts. Body text lives in word/document.xml. Two tiers:
- Default —
python-docx(preinstalled): create, read, and simple edits. Use for almost everything. - Advanced — raw OOXML via
zipfile: only for what python-docx cannot express — tracked changes (redlines), comments, and exact-fidelity edits that must preserve every untouched byte. See Raw OOXML.
Runtime
Use exec with complete Python source (language: python). python-docx is
preinstalled. Prefer creating, saving, reopening, and validating the deliverable
in one call; later calls can revise the same relative filename. Follow the
turn's User workspace instructions for locating inputs, output boundaries,
and presenting the finished file. When editing, write a new output unless the
user explicitly requested an authorized replacement.
Read / extract
from docx import Document
doc = Document("in.docx")
text = "\n".join(p.text for p in doc.paragraphs) # body paragraphs
for tbl in doc.tables: # tables
for row in tbl.rows:
print([c.text for c in row.cells])
doc.paragraphs skips text inside tables, headers/footers, and text boxes — iterate doc.tables and doc.sections[i].header/.footer for those. Each paragraph's style: p.style.name (e.g. "Heading 1").
To read tracked changes, parse the XML directly — python-docx ignores <w:ins>/<w:del>:
import zipfile, re
xml = zipfile.ZipFile("in.docx").read("word/document.xml").decode("utf-8")
# inserted text = <w:ins>…<w:t>… deleted = <w:del>…<w:delText>…
print(re.findall(r"<w:t[^>]*>(.*?)</w:t>", xml))
Create
from docx import Document
from docx.shared import Pt, Inches, RGBColor
from docx.enum.text import WD_ALIGN_PARAGRAPH
doc = Document() # default template page size
doc.add_heading("Quarterly Report", level=0) # 0 = title; 1..9 = H1..H9
p = doc.add_paragraph("Intro paragraph. ")
run = p.add_run("Bold tail.")
run.bold = True
doc.add_paragraph("First item", style="List Bullet") # real list style, never a "• " literal
doc.add_paragraph("Step one", style="List Number")
# Table — header row + data
tbl = doc.add_table(rows=1, cols=2)
tbl.style = "Light Grid Accent 1"
tbl.rows[0].cells[0].text, tbl.rows[0].cells[1].text = "Metric", "Value"
for k, v in [("Revenue", "1.2M"), ("Growth", "15%")]:
c = tbl.add_row().cells
c[0].text, c[1].text = k, v
doc.add_picture("chart.png", width=Inches(5)) # image, scaled to width
doc.add_page_break()
doc.save("out.docx")
# Validate immediately; later exec calls can also reopen this relative path.
check = Document("out.docx")
assert check.paragraphs, "generated DOCX has no paragraphs"
import zipfile
with zipfile.ZipFile("out.docx") as package:
assert package.testzip() is None, "generated DOCX has a corrupt ZIP member"
Rules:
- Never type bullet/number characters (
•,1.) into text — usestyle="List Bullet"/"List Number". Only list styles defined in the doc's template are available. - No
\ninside a run — each visual line is its ownadd_paragraph. - Built-in style names must match the template (e.g.
"Heading 1","List Bullet"); a wrong name raisesKeyError. - Units:
Pt,Inches,Cmfromdocx.shared. Colors:RGBColor(0x1F,0x4E,0x79).
Page setup, headers/footers, page numbers
from docx.shared import Inches
sec = doc.sections[0]
sec.page_width, sec.page_height = Inches(8.5), Inches(11) # Letter
sec.top_margin = sec.bottom_margin = Inches(1)
sec.header.paragraphs[0].text = "Confidential"
Page-number fields aren't in the python-docx API; inject the field XML into a footer run:
from docx.oxml.ns import qn
from docx.oxml import OxmlElement
def add_page_number(paragraph):
for t in ("begin", "instr", "end"):
r = OxmlElement("w:r")
if t == "instr":
fld = OxmlElement("w:instrText")
fld.set(qn("xml:space"), "preserve")
fld.text = "PAGE"
else:
fld = OxmlElement("w:fldChar")
fld.set(qn("w:fldCharType"), t)
r.append(fld)
paragraph._p.append(r)
add_page_number(doc.sections[0].footer.paragraphs[0])
A clickable Table of Contents is also a field; Word shows "right-click → Update Field" until refreshed. Same pattern with instrText = TOC \o "1-3" \h \z \u.
Edit existing (simple)
python-docx preserves the rest of the doc
अक्सर पूछे जाने वाले सवाल
क्या यह PDF या Excel फ़ाइलों के साथ काम करती है?
नहीं। यह स्किल Word फ़ाइलों के लिए है, और बताती है कि PDF, Excel, PowerPoint और Google Docs इसके दायरे से बाहर हैं।
क्या यह table of contents जोड़ सकती है?
हाँ। स्किल में table of contents और पेज नंबर शामिल हैं।
क्या यह tracked changes बना सकती है?
हाँ। यह अपनी उन्नत विधि से tracked changes और comments लागू कर सकती है।
जानकारी
लेखक का मूल विवरण
Read, create, or edit Microsoft Word .docx files — extract/summarize text and tables, generate reports/letters/memos with headings, tables, images, TOC and page numbers, do find-and-replace, or apply tracked changes (redlines) and comments. Use whenever the user has a .docx or wants a Word deliverable. Not for PDF, .xlsx, .pptx, or Google Docs.
repo: HKUDS/DeepTutor
लोकप्रियता
- GitHub स्टार
- 54k
- रैंकिंग में स्थान
- #3368
- लाइसेंस
- Apache-2.0
- अपडेट की गई
- 31/10/2026
कमेंट
- …
इस repository की और skills
deeptutor-cli
54kयह आपके एजेंट को कमांड लाइन से DeepTutor, एक लर्निंग प्लेटफ़ॉर्म, सेट करने और चलाने में मदद करती है, जिसमें knowledge bases, notebooks और web ऐप शामिल हैं।
आपके एजेंट को PDF फ़ाइलें पढ़ने, मिलाने, बाँटने, भरने और बनाने में मदद करती है, जिनमें उनसे टेक्स्ट और टेबल निकालना भी शामिल है।
pptx
54kआपके एजेंट को PowerPoint deck बनाने, पढ़ने और संपादित करने देती है, जिनमें स्लाइड का टेक्स्ट, speaker notes, charts और images शामिल हैं।
skill-creator
54kआपके एजेंट को DeepTutor skills लिखना या सुधारना सिखाती है, यानी वे छोटे निर्देश पैकेज जो AI को एक खास काम सिखाते हैं।
मिलती-जुलती skills
feishu-doc
394kयह आपके एजेंट को document टूल से Feishu क्लाउड दस्तावेज़ पढ़ने, बनाने और बदलने में मदद करती है, जिसमें टेक्स्ट, इमेज और टेबल शामिल हैं।
feishu-drive
394kयह आपके एजेंट को बॉट के साथ साझा किए गए Feishu क्लाउड फ़ोल्डर में फ़ाइलें देखने, व्यवस्थित करने और उन पर टिप्पणी करने देती है।
feishu-perm
394kयह आपके एजेंट को Feishu फ़ाइल तक किसकी पहुंच है, यह जांचने और बदलने देती है, और आपके अनुरोध के लिए सबसे छोटी अनुमति चुनती है।