欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

無需邀請碼!Manus復(fù)刻開源版OpenManus下載安裝與體驗(yàn)

 更新時(shí)間:2025年07月24日 09:44:22   投稿:wdc  
Manus的完美復(fù)刻開源版OpenManus安裝與體驗(yàn),無需邀請碼,手把手教你如何在本地安裝與配置Manus的開源版OpenManus

Manus是什么?

Manus 是 Monica 團(tuán)隊(duì)推出的全球首款通用型 AI Agent。Manus能獨(dú)立思考、規(guī)劃和執(zhí)行復(fù)雜任務(wù),直接交付完整成果。與傳統(tǒng) AI 不同,Manus 擁有強(qiáng)大的工具調(diào)用能力,能自主完成從任務(wù)規(guī)劃到執(zhí)行的全流程,如文件處理、數(shù)據(jù)分析、代碼編寫、內(nèi)容創(chuàng)作等。Manus在 GAIA 基準(zhǔn)測試中表現(xiàn)優(yōu)異,遠(yuǎn)超OpenAI的Deep Research。Manus 的設(shè)計(jì)理念是“知行合一”,基于智能化手段擴(kuò)展人類能力,成為人類的智能伙伴。目前,Manus 仍處于內(nèi)測階段,需要使用邀請碼登錄使用。

說人話就是,你告訴他任務(wù)的目標(biāo)或方案,他給你干活,并自動給你一個(gè)最終結(jié)果比如幫你處理文件、分析數(shù)據(jù)、寫代碼、創(chuàng)作內(nèi)容等,而這些都是一氣呵成的,不需要人工干預(yù)

OpenManus又是什么?

OpenManus 是 MetaGPT 團(tuán)隊(duì)推出的開源復(fù)刻版 Manus,提供無需邀請碼的 AI Agent 。OpenManus基于模塊化設(shè)計(jì),支持多種語言模型和工具鏈,能執(zhí)行代碼、處理文件、搜索網(wǎng)絡(luò)信息等復(fù)雜任務(wù)。OpenManus 的核心優(yōu)勢在于實(shí)時(shí)反饋機(jī)制,用戶能直觀看到 AI 的思考過程和任務(wù)執(zhí)行進(jìn)度。OpenManus具備強(qiáng)大的工具鏈和靈活的配置選項(xiàng),方便開發(fā)者根據(jù)需求進(jìn)行定制。 

簡單來說 OpenManus是的開源版,Manus能做的事情,OpenManus也可以實(shí)現(xiàn),并且OpenManus還可以安裝在本地,無需服務(wù)器,無需多高性能的電腦配置,只需要一個(gè)像Deepseek,或ChatGPT的API賬號即可使用

OpenManus環(huán)境配置與安裝

使用OpenManus官方推薦uv安裝方法:Python3.11+UV

UV是由Astral公司(Rust工具Ruff的開發(fā)者)推出的高性能Python包管理工具,基于Rust編寫,旨在替代傳統(tǒng)的pippip-tools。其核心優(yōu)勢在于極快的速度(比pip快10-100倍)、輕量級設(shè)計(jì)(僅幾十MB)以及現(xiàn)代化的依賴管理(支持pyproject.tomluv.lock文件)。UV集成了虛擬環(huán)境管理、Python版本控制、依賴解析等功能,目標(biāo)是成為類似Rust Cargo的全能工具,簡化Python開發(fā)流程。

在Windows上安裝UV的2種方法

通過PIP安裝(推薦)直接使用Python自帶的pip安裝,兼容性最佳:

pip install uv

安裝后,uv會被添加到系統(tǒng)環(huán)境變量,即使切換虛擬環(huán)境也能使用。

PowerShell腳本安裝打開PowerShell,執(zhí)行:

irm https://astral.sh/uv/install.ps1 | iex

克隆OpenManus存儲庫:

git clone https://github.com/mannaandpoem/OpenManus.git
cd OpenManus

如果你沒有安裝git或者無法通過git克隆OpenManus源碼時(shí)出錯(cuò),可以掃碼下面的二維碼關(guān)注公眾號【Python客棧】并回復(fù)【OpenManus】下載OpenManus源碼

關(guān)注公眾號【Python客棧】并回復(fù)【OpenManus】下載OpenManus源碼

克隆或下載完成后,進(jìn)入OpenManus項(xiàng)目的根目錄。在路徑欄輸入cmd,回車,進(jìn)入OpenManus根目錄路徑下的控制臺。 

輸入uv venv創(chuàng)建一個(gè)新的虛擬環(huán)境并激活它:

uv venv
#Unix/macOS返回
source .venv/bin/activate

#Windows返回:
.venv\Scripts\activate

安裝OpenManus依賴項(xiàng):

uv pip install -r requirements.txt

 執(zhí)行命令后返回下面內(nèi)容

C:\OpenManus\OpenManus-main>uv pip install -r requirements.txt
Resolved 133 packages in 2m 36s
      Built english-words==2.0.1
      Built html2text==2024.2.26
Prepared 132 packages in 2m 50s
Installed 133 packages in 10.19s
 + aiofiles==24.1.0
 + aiohappyeyeballs==2.5.0
 + aiohttp==3.11.13
 + aiolimiter==1.2.1
 + aiosignal==1.3.2
 + annotated-types==0.7.0
 + anthropic==0.49.0
 + anyio==4.8.0
 + attrs==25.1.0
 + backoff==2.2.1
 + beartype==0.12.0
 + beautifulsoup4==4.13.3
 + blinker==1.9.0
 + browser-use==0.1.40
 + browsergym==0.13.3
 + browsergym-assistantbench==0.13.3
 + browsergym-core==0.13.3
 + browsergym-experiments==0.13.3
 + browsergym-miniwob==0.13.3
 + browsergym-visualwebarena==0.13.3
 + browsergym-webarena==0.13.3
 + browsergym-workarena==0.4.1
 + certifi==2025.1.31
 + charset-normalizer==3.4.1
 + click==8.1.8
 + cloudpickle==3.1.1
 + colorama==0.4.6
 + dataclasses-json==0.6.7
 + datasets==3.2.0
 + defusedxml==0.7.1
 + dill==0.3.8
 + distro==1.9.0
 + english-words==2.0.1
 + evaluate==0.4.3
 + faker==37.0.0
 + farama-notifications==0.0.4
 + filelock==3.17.0
 + flask==3.1.0
 + frozenlist==1.5.0
 + fsspec==2024.9.0
 + googlesearch-python==1.3.0
 + greenlet==3.1.1
 + gymnasium==1.0.0
 + h11==0.14.0
 + html2text==2024.2.26
 + httpcore==1.0.7
 + httpx==0.28.1
 + huggingface-hub==0.29.2
 + idna==3.10
 + imageio==2.37.0
 + itsdangerous==2.2.0
 + jinja2==3.1.6
 + jiter==0.8.2
 + joblib==1.4.2
 + jsonpatch==1.33
 + jsonpointer==3.0.0
 + langchain-anthropic==0.3.3
 + langchain-core==0.3.43
 + langchain-ollama==0.2.2
 + langchain-openai==0.3.1
 + langsmith==0.3.13
 + lazy-loader==0.4
 + libvisualwebarena==0.0.15
 + libwebarena==0.0.4
 + loguru==0.7.3
 + lxml==5.3.1
 + markdownify==0.14.1
 + markupsafe==3.0.2
 + marshmallow==3.26.1
 + monotonic==1.6
 + mpmath==1.3.0
 + multidict==6.1.0
 + multiprocess==0.70.16
 + mypy-extensions==1.0.0
 + networkx==3.4.2
 + nltk==3.9.1
 + numpy==2.2.3
 + ollama==0.4.7
 + openai==1.58.1
 + orjson==3.10.15
 + packaging==24.2
 + pandas==2.2.3
 + pillow==10.4.0
 + playwright==1.49.1
 + portalocker==3.1.1
 + posthog==3.19.0
 + propcache==0.3.0
 + pyarrow==19.0.1
 + pydantic==2.10.6
 + pydantic-core==2.27.2
 + pyee==12.0.0
 + pyparsing==3.2.1
 + python-dateutil==2.9.0.post0
 + python-dotenv==1.0.1
 + pytz==2025.1
 + pywin32==309
 + pyyaml==6.0.2
 + regex==2024.11.6
 + requests==2.32.3
 + requests-toolbelt==1.0.0
 + sacrebleu==2.5.1
 + safetensors==0.5.3
 + scikit-image==0.25.2
 + scipy==1.15.2
 + setuptools==76.0.0
 + six==1.17.0
 + sniffio==1.3.1
 + soupsieve==2.6
 + sympy==1.13.1
 + tabulate==0.9.0
 + tenacity==9.0.0
 + text-generation==0.7.0
 + tifffile==2025.2.18
 + tiktoken==0.9.0
 + tokenizers==0.21.0
 + torch==2.6.0
 + tqdm==4.67.1
 + transformers==4.49.0
 + types-requests==2.32.0.20250306
 + types-tqdm==4.67.0.20250301
 + typing-extensions==4.12.2
 + typing-inspect==0.9.0
 + tzdata==2025.1
 + unidiff==0.7.5
 + urllib3==2.3.0
 + uvicorn==0.34.0
 + weblinx==0.3.2
 + weblinx-browsergym==0.0.1.dev14
 + werkzeug==3.1.3
 + win32-setctime==1.2.0
 + xxhash==3.5.0
 + yarl==1.18.3
 + zstandard==0.23.0

配置OpenManus

在OpenManus根目錄下找到并進(jìn)入config目錄

編輯config.toml文件,配置API地址和API Key。

大語言模型API配置問題

在嘗試了多個(gè)模型后,總結(jié)出以下配置是效果最好的:

# DeepSeek V3配置(國內(nèi)最佳選擇)
[llm]
model = "deepseek-v3"
base_url = "https://api.deepseek.com/v1"
api_key = "你的API密鑰"  # 替換為你的實(shí)際密鑰
max_tokens = 8192
temperature = 0.0

# 通義千問配置(國產(chǎn)模型備選)
[llm]
model = "qwen-turbo"
base_url = "https://dashscope.aliyuncs.com/api/v1"
api_key = "你的阿里云API密鑰"
max_tokens = 4096
temperature = 0.0

# Claude配置(國外用戶推薦)
[llm]
model = "claude-3-5-sonnet"
base_url = "https://api.anthropic.com"
api_key = "你的Anthropic API密鑰"
max_tokens = 4096
temperature = 0.0

使用OpenManus的實(shí)際體驗(yàn)與建議

經(jīng)過兩天的深度使用,結(jié)合GitHub Issues中的反饋,總結(jié)了以下經(jīng)驗(yàn):

不同模型的實(shí)際表現(xiàn)

通過系統(tǒng)測試,發(fā)現(xiàn)不同模型在OpenManus中的表現(xiàn)有明顯差異:

模型工具調(diào)用能力中文理解執(zhí)行效率我的評分
DeepSeek-v3優(yōu)秀,支持完整函數(shù)調(diào)用極佳快速★★★★★
Claude-3.5良好,少量格式問題很好中等★★★★☆
Qwen-Turbo中等,需要特殊處理極佳快速★★★★☆
GPT-4o優(yōu)秀,工具調(diào)用穩(wěn)定良好較慢★★★★☆
GPT-4o-mini不穩(wěn)定,經(jīng)常需要重試中等快速★★★☆☆

實(shí)戰(zhàn)演示:從SEO審核到自動化報(bào)告

Karpathy個(gè)人網(wǎng)站SEO優(yōu)化任務(wù)為例,OpenManus的運(yùn)作流程展現(xiàn)其強(qiáng)大能力:

  • 任務(wù)解析階段智能體將用戶指令拆解為:
  • 網(wǎng)站元數(shù)據(jù)抓取
  • 技術(shù)SEO檢測(站點(diǎn)地圖、響應(yīng)速度等)
  • 內(nèi)容優(yōu)化建議生成
  • 工具調(diào)用過程
  • 通過BrowserUseTool抓取https://karpathy.ai/的HTML結(jié)構(gòu)
  • 使用PythonExecute運(yùn)行SEO分析腳本
  • 調(diào)用GoogleSearch驗(yàn)證關(guān)鍵詞競爭度
  • 結(jié)果輸出最終生成包含優(yōu)先級排序的優(yōu)化報(bào)告,例如:
  • 高優(yōu)先級:為圖片添加Alt文本(當(dāng)前缺失率78%)
  • 中優(yōu)先級:實(shí)施Schema標(biāo)記增強(qiáng)搜索引擎理解
  • 基礎(chǔ)優(yōu)化:壓縮CSS/JS文件提升加載速度

國內(nèi)使用的時(shí)候會出現(xiàn)多次報(bào)錯(cuò),因?yàn)槌绦蛟O(shè)計(jì)的原因使用的搜索等功能都是基于google做的,所以會出現(xiàn)部分瀏覽器抓取等失敗的問題,不過下面的搜索功能與模塊替換已經(jīng)給出解決方法,這里就需要自己解決了,你們懂得!

技術(shù)對比:OpenManus與Manus的異同

維度ManusOpenManus
架構(gòu)設(shè)計(jì)閉源商業(yè)系統(tǒng)開源ReAct框架
規(guī)劃能力線性任務(wù)鏈支持DAG有向無環(huán)圖擴(kuò)展
模型支持僅限Claude系列兼容Qwen/GPT-4等主流模型
執(zhí)行反饋可視化進(jìn)度條終端日志實(shí)時(shí)輸出

值得注意的是,OpenManus當(dāng)前版本在任務(wù)規(guī)劃的細(xì)膩度上略遜于Manus,但其開源特性允許社區(qū)開發(fā)者持續(xù)優(yōu)化工具鏈與提示工程

安裝與環(huán)境配置問題

依賴安裝錯(cuò)誤

問題表現(xiàn)
playwright安裝失敗。

解決方案

# 分步安裝能解決大部分依賴問題
pip install --no-deps -r requirements.txt

# 對于playwright,使用這個(gè)方法成功解決了問題
pip install playwright==1.40.0 --no-build-isolation
playwright install chromium

# 如果仍然遇到問題,嘗試手動安裝核心依賴
pip install pydantic==2.5.2 langchain==0.1.6 beautifulsoup4==4.12.3

Windows特有問題解決

問題表現(xiàn)
在Windows環(huán)境下,遇到了一些Linux環(huán)境中沒有的問題,特別是路徑和編碼相關(guān)的錯(cuò)誤。

解決方案

# 在Windows中處理路徑時(shí)使用了這種方式統(tǒng)一處理
import os
def normalize_path(path):
    """統(tǒng)一處理Windows和Linux路徑"""
    return os.path.normpath(path).replace('\\', '/')

API調(diào)用錯(cuò)誤的故障排除

遇到的幾個(gè)常見API錯(cuò)誤及解決方法:

問題表現(xiàn)1
經(jīng)常遇到"API error: Error code: 400"錯(cuò)誤。

解決方案

# 修改了app/llm.py,增加了更詳細(xì)的錯(cuò)誤處理
def call_api_with_detailed_error(self, *args, **kwargs):
    try:
        return self._call_api(*args, **kwargs)
    except Exception as e:
        error_msg = str(e)
        if "400" in error_msg:
            # 檢查請求參數(shù)
            print("API 400錯(cuò)誤排查清單:")
            print("1. 檢查API密鑰格式是否正確")
            print("2. 檢查模型名稱是否正確")
            print("3. 檢查請求參數(shù)格式")
            print("4. 原始錯(cuò)誤信息:", error_msg)
        elif "401" in error_msg:
            print("認(rèn)證失敗,請檢查API密鑰")
        elif "429" in error_msg:
            print("請求頻率過高,請降低請求速度或升級API配額")
        raise e

問題表現(xiàn)2
"not support function calling"問題

解決方案
DeepSeek最新版本已支持函數(shù)調(diào)用。

Token限制問題的實(shí)際解決方法

問題表現(xiàn)
“max_token最大允許8192,太小了”,導(dǎo)致復(fù)雜任務(wù)無法完成。

解決方案

# 實(shí)現(xiàn)了一個(gè)上下文管理器,大大提高了長任務(wù)的完成率
def manage_context_length(context, max_length=6000, summarize_threshold=7500):
    """智能管理上下文長度"""
    if len(context) < summarize_threshold:
        return context
    
    # 將上下文分為三部分處理
    intro = context[:1500]  # 保留初始指令
    recent = context[-3000:]  # 保留最近交互
    middle = context[1500:-3000]  # 中間部分需要壓縮
    
    # 對中間部分進(jìn)行摘要
    from app.llm import LLM
    llm = LLM()
    summary_prompt = f"請將以下對話歷史壓縮為簡短摘要,保留關(guān)鍵信息:\n\n{middle}"
    summary = llm.generate(summary_prompt, max_tokens=1500)
    
    # 組合處理后的上下文
    new_context = intro + "\n\n[歷史摘要]: " + summary + "\n\n" + recent
    return new_context

搜索功能與模塊替換

由于Google搜索在國內(nèi)無法使用,這個(gè)問題在GitHub Issues中被多次提到。

Bing搜索實(shí)現(xiàn)

進(jìn)一步優(yōu)化了Bing搜索實(shí)現(xiàn):

# app/tool/bing_search.py
from typing import Dict, List, Optional
import os
import requests
from pydantic import Field
from app.logger import logger
from app.tool.base import BaseTool

class BingSearch(BaseTool):
    """使用必應(yīng)搜索引擎進(jìn)行網(wǎng)絡(luò)搜索"""
    
    name: str = "bing_search"
    description: str = "使用必應(yīng)搜索查詢信息,對于需要最新信息的查詢特別有用"
    
    def __init__(self):
        super().__init__()
        # 從環(huán)境變量或配置文件獲取API密鑰
        self.subscription_key = os.environ.get("BING_API_KEY", "你的Bing搜索API密鑰")
        self.search_url = "https://api.bing.microsoft.com/v7.0/search"
    
    def _call(self, query: str, num_results: int = 10) -> Dict:
        """執(zhí)行必應(yīng)搜索"""
        headers = {"Ocp-Apim-Subscription-Key": self.subscription_key}
        params = {
            "q": query, 
            "count": num_results, 
            "textDecorations": True, 
            "textFormat": "HTML",
            "mkt": "zh-CN"  # 設(shè)置為中文市場,結(jié)果更符合國內(nèi)用戶習(xí)慣
        }
        
        try:
            response = requests.get(self.search_url, headers=headers, params=params)
            response.raise_for_status()
            search_results = response.json()
            
            # 提取有用的搜索結(jié)果
            results = []
            if "webPages" in search_results and "value" in search_results["webPages"]:
                for result in search_results["webPages"]["value"]:
                    results.append({
                        "title": result["name"],
                        "link": result["url"],
                        "snippet": result["snippet"],
                        "dateLastCrawled": result.get("dateLastCrawled", "")
                    })
            
            # 添加新聞結(jié)果
            if "news" in search_results and "value" in search_results["news"]:
                for news in search_results["news"]["value"][:3]:  # 取前3條新聞
                    results.append({
                        "title": "[新聞] " + news["name"],
                        "link": news["url"],
                        "snippet": news["description"],
                        "datePublished": news.get("datePublished", "")
                    })
            
            return {
                "query": query,
                "results": results,
                "total_results": len(results)
            }
            
        except Exception as e:
            logger.error(f"必應(yīng)搜索出錯(cuò): {str(e)}")
            return {
                "query": query,
                "results": [],
                "total_results": 0,
                "error": str(e)
            }

百度搜索替代實(shí)現(xiàn)

將Google搜索替換成百度搜索"

# app/tool/baidu_search.py
import requests
from bs4 import BeautifulSoup
from pydantic import Field
from app.tool.base import BaseTool
from app.logger import logger

class BaiduSearch(BaseTool):
    """使用百度搜索引擎進(jìn)行網(wǎng)絡(luò)搜索"""
    
    name: str = "baidu_search"
    description: str = "使用百度搜索獲取信息,適合中文搜索"
    
    def _call(self, query: str, num_results: int = 10) -> dict:
        """執(zhí)行百度搜索并解析結(jié)果"""
        headers = {
            "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
            "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8"
        }
        
        search_url = f"https://www.baidu.com/s?wd={query}&rn={num_results}"
        
        try:
            response = requests.get(search_url, headers=headers, timeout=10)
            response.raise_for_status()
            response.encoding = 'utf-8'
            
            soup = BeautifulSoup(response.text, 'html.parser')
            search_results = soup.select('.result.c-container')
            
            results = []
            for result in search_results[:num_results]:
                title_elem = result.select_one('.t')
                link_elem = title_elem.select_one('a') if title_elem else None
                abstract_elem = result.select_one('.c-abstract')
                
                if title_elem and link_elem:
                    title = title_elem.get_text(strip=True)
                    link = link_elem.get('href', '')
                    abstract = abstract_elem.get_text(strip=True) if abstract_elem else "無描述"
                    
                    results.append({
                        "title": title,
                        "link": link,
                        "snippet": abstract
                    })
            
            return {
                "query": query,
                "results": results,
                "total_results": len(results)
            }
            
        except Exception as e:
            logger.error(f"百度搜索出錯(cuò): {str(e)}")
            return {
                "query": query,
                "results": [],
                "total_results": 0,
                "error": str(e)
            }

搜索功能的注冊方法

按照以下步驟將新的搜索工具集成到OpenManus中:

# 修改app/agent/manus.py文件
from app.tool.bing_search import BingSearch
from app.tool.baidu_search import BaiduSearch

# 找到available_tools部分并替換
available_tools: ToolCollection = Field(
    default_factory=lambda: ToolCollection(
        PythonExecute(), 
        BaiduSearch(),  # 國內(nèi)用戶首選
        BingSearch(),   # 備選搜索工具
        BrowserUseTool(), 
        FileSaver(), 
        Terminate()
    )
)

執(zhí)行控制與錯(cuò)誤處理

循環(huán)檢測與自動中斷

解決了"loop error"、"任務(wù)完成后的重復(fù)思考"問題:

# 在app/agent/base.py中添加了循環(huán)檢測功能
def is_in_loop(self, actions_history, threshold=3, similarity_threshold=0.85):
    """檢測是否陷入執(zhí)行循環(huán)"""
    if len(actions_history) < threshold * 2:
        return False
    
    recent_actions = actions_history[-threshold:]
    previous_actions = actions_history[-(threshold*2):-threshold]
    
    # 計(jì)算最近動作與前一批動作的相似度
    similarity_count = 0
    for i in range(threshold):
        # 使用簡單字符串相似度
        current = recent_actions[i]
        previous = previous_actions[i]
        
        # 如果動作類型、參數(shù)等關(guān)鍵信息相似
        if current['tool'] == previous['tool'] and \
           self._params_similarity(current['params'], previous['params']) > similarity_threshold:
            similarity_count += 1
    
    # 如果超過一定比例的動作重復(fù),判定為循環(huán)
    return similarity_count / threshold > 0.7

def _params_similarity(self, params1, params2):
    """計(jì)算兩組參數(shù)的相似度"""
    # 簡化實(shí)現(xiàn),實(shí)際使用中可以采用更復(fù)雜的相似度算法
    if params1 == params2:
        return 1.0
    
    common_keys = set(params1.keys()) & set(params2.keys())
    if not common_keys:
        return 0.0
    
    similarity = 0
    for key in common_keys:
        if params1[key] == params2[key]:
            similarity += 1
    
    return similarity / len(common_keys)

在執(zhí)行流程中添加循環(huán)檢測:

# 在執(zhí)行流程中使用循環(huán)檢測
def run(self, prompt):
    actions_history = []
    
    for step in range(self.max_steps):
        action = self.plan_next_action(prompt)
        actions_history.append(action)
        
        # 檢測是否陷入循環(huán)
        if len(actions_history) > 6 and self.is_in_loop(actions_history):
            logger.warning("檢測到執(zhí)行循環(huán),嘗試重新規(guī)劃...")
            # 添加特殊提示,幫助模型跳出循環(huán)
            prompt += "\n\n[系統(tǒng)提示]: 檢測到可能的執(zhí)行循環(huán),請嘗試不同的解決方案或工具。"
            continue
        
        result = self.execute_action(action)
        
        if self.is_task_complete():
            return result
    
    return "達(dá)到最大步驟數(shù),任務(wù)未完成"

文件保存問題的實(shí)際解決

針對"更改了file_path控制臺輸出文件已保存,但實(shí)際上并沒有保存"的問題,修改FileSaver工具:

# 改進(jìn)的FileSaver工具實(shí)現(xiàn)
def save_file_with_verification(self, content, file_path, overwrite=False):
    """保存文件并驗(yàn)證成功與否"""
    # 規(guī)范化路徑
    file_path = os.path.abspath(file_path)
    
    # 檢查目錄是否存在,不存在則創(chuàng)建
    dir_path = os.path.dirname(file_path)
    if not os.path.exists(dir_path):
        try:
            os.makedirs(dir_path, exist_ok=True)
        except Exception as e:
            return f"創(chuàng)建目錄失敗: {dir_path}, 錯(cuò)誤: {str(e)}"
    
    # 檢查文件是否已存在
    if os.path.exists(file_path) and not overwrite:
        return f"文件已存在且未設(shè)置覆蓋: {file_path}"
    
    # 保存文件
    try:
        if isinstance(content, str):
            with open(file_path, 'w', encoding='utf-8') as f:
                f.write(content)
        else:
            with open(file_path, 'wb') as f:
                f.write(content)
        
        # 驗(yàn)證文件是否成功保存
        if os.path.exists(file_path) and os.path.getsize(file_path) > 0:
            return f"文件成功保存到: {file_path}"
        else:
            return f"文件保存失敗,雖然沒有報(bào)錯(cuò)但文件為空: {file_path}"
    except Exception as e:
        return f"保存文件出錯(cuò): {str(e)}"

Manus出現(xiàn)短短幾小時(shí)開源社區(qū)就有了復(fù)刻開源版本OpenManus,說明Manus確實(shí)具備較強(qiáng)的創(chuàng)新性和吸引力,有了開源項(xiàng)目,讓我們這些沒錢沒設(shè)備的普通開發(fā)者也可以體驗(yàn)嘗試AI的創(chuàng)造力讓人十分激活

相關(guān)文章

  • Python+Selenium實(shí)現(xiàn)一鍵摸魚&采集數(shù)據(jù)

    Python+Selenium實(shí)現(xiàn)一鍵摸魚&采集數(shù)據(jù)

    將Selenium程序編寫為 .bat 可執(zhí)行文件,從此一鍵啟動封裝好的Selenium程序,省時(shí)省力還可以復(fù)用,豈不美哉。所以本文將利用Selenium實(shí)現(xiàn)一鍵摸魚&一鍵采集數(shù)據(jù),需要的可以參考一下
    2022-08-08
  • python?如何去除字符串中指定字符

    python?如何去除字符串中指定字符

    python中的strip()可以去除頭尾指定字符,只能刪除頭尾指定字符,想要去除中間字符,可以使用replace()函數(shù),本文結(jié)合示例代碼給大家介紹的非常詳細(xì),需要的朋友參考下吧
    2022-12-12
  • Python的命令行參數(shù)實(shí)例詳解

    Python的命令行參數(shù)實(shí)例詳解

    python中有一個(gè)模塊sys,sys.argv這個(gè)屬性提供了對命令行參數(shù)的訪問,下面這篇文章主要給大家介紹了關(guān)于Python命令行參數(shù)實(shí)例的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2022-02-02
  • 使用matplotlib動態(tài)刷新指定曲線實(shí)例

    使用matplotlib動態(tài)刷新指定曲線實(shí)例

    這篇文章主要介紹了使用matplotlib動態(tài)刷新指定曲線實(shí)例,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-04-04
  • Python?ini配置文件示例詳解

    Python?ini配置文件示例詳解

    這篇文章主要給大家介紹了關(guān)于Python?ini配置文件的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2022-03-03
  • python程序文件擴(kuò)展名知識點(diǎn)詳解

    python程序文件擴(kuò)展名知識點(diǎn)詳解

    在本篇文章里小編給大家整理的是關(guān)于python程序文件擴(kuò)展名知識點(diǎn)詳解內(nèi)容,需要的朋友們學(xué)習(xí)參考下。
    2020-02-02
  • python對excel文檔去重及求和的實(shí)例

    python對excel文檔去重及求和的實(shí)例

    下面小編就為大家分享一篇python對excel文檔去重及求和的實(shí)例,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-04-04
  • python基礎(chǔ)教程之縮進(jìn)介紹

    python基礎(chǔ)教程之縮進(jìn)介紹

    這篇文章主要介紹了python基礎(chǔ)教程之縮進(jìn)介紹,本文以if語句為例講解python中的縮進(jìn),需要的朋友可以參考下
    2014-08-08
  • Python unittest discover批量執(zhí)行代碼實(shí)例

    Python unittest discover批量執(zhí)行代碼實(shí)例

    這篇文章主要介紹了Python unittest discover批量執(zhí)行代碼實(shí)例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-09-09
  • 編寫同時(shí)兼容Python2.x與Python3.x版本的代碼的幾個(gè)示例

    編寫同時(shí)兼容Python2.x與Python3.x版本的代碼的幾個(gè)示例

    這篇文章主要介紹了編寫同時(shí)兼容Python2.x與Python3.x版本的代碼的幾個(gè)示例,在Python2.7.x的更新中由于采用了某些Python3中的代碼編寫特性、使得在有些原本不同之處編寫兼容性代碼成為可能,需要的朋友可以參考下
    2015-03-03

最新評論