执行 Python 代码片段,进行数据处理、计算和文件操作
使用 Python 执行用户请求的代码片段,支持数据计算、文件处理、文本分析等。
生成一条 python -c '...' 命令执行用户需要的代码逻辑。
python -c "
import math
# 根据用户需求编写计算逻辑
result = math.sqrt(144) + math.pi
print(f'计算结果: {result}')
"
python -c "
import json
data = [{'name':'张三','score':85},{'name':'李四','score':92},{'name':'王五','score':78}]
avg = sum(d['score'] for d in data) / len(data)
top = max(data, key=lambda x: x['score'])
print(f'平均分: {avg:.1f}')
print(f'最高分: {top[\"name\"]} ({top[\"score\"]}分)')
"
python -c "
import csv,io
csv_text='姓名,科目,分数\n张三,数学,85\n李四,数学,92\n王五,数学,78'
reader=csv.DictReader(io.StringIO(csv_text))
rows=list(reader)
scores=[int(r['分数']) for r in rows]
print(f'总人数: {len(rows)}')
print(f'平均分: {sum(scores)/len(scores):.1f}')
print(f'最高分: {max(scores)}')
print(f'最低分: {min(scores)}')
"
python -c "
import re
text='联系方式: 13812345678, email: test@example.com, 备用: 15987654321'
phones=re.findall(r'1[3-9]\d{9}',text)
emails=re.findall(r'[\w.+-]+@[\w-]+\.[\w.]+',text)
print(f'手机号: {phones}')
print(f'邮箱: {emails}')
"
python -c "
from datetime import datetime,timedelta
now=datetime.now()
print(f'当前时间: {now.strftime(\"%Y-%m-%d %H:%M:%S\")}')
print(f'30天后: {(now+timedelta(days=30)).strftime(\"%Y-%m-%d\")}')
print(f'今年已过: {now.timetuple().tm_yday} 天')
print(f'距年底还有: {(datetime(now.year,12,31)-now).days} 天')
"
python -c "
import base64,hashlib
text='Hello World'
print(f'原文: {text}')
print(f'Base64: {base64.b64encode(text.encode()).decode()}')
print(f'MD5: {hashlib.md5(text.encode()).hexdigest()}')
print(f'SHA256: {hashlib.sha256(text.encode()).hexdigest()}')
print(f'十六进制: {text.encode().hex()}')
"
python -c "
import random,string
pwd=''.join(random.choices(string.ascii_letters+string.digits+'!@#$%',k=16))
uuid_like=''.join(random.choices('0123456789abcdef',k=32))
uuid_fmt=f'{uuid_like[:8]}-{uuid_like[8:12]}-{uuid_like[12:16]}-{uuid_like[16:20]}-{uuid_like[20:]}'
print(f'随机密码: {pwd}')
print(f'随机UUID: {uuid_fmt}')
print(f'随机数(1-100): {random.randint(1,100)}')
"
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer