我最近將我的代碼從 Jupyter 帶到了 VSCode。我修復了匯入的一些問題,但現在我找不到 .csv 檔案。代碼和 .csv 檔案保存在同一個檔案夾中。我的代碼是:
import pandas
df = pandas.read_csv('emailss.csv', names=['Email', 'Amiability'])
運行程式后,它說,
FileNotFoundError: [Errno 2] No such file or directory: 'emailss.csv'
這里發生了什么?我該如何解決?它在 Jupyter 中運行良好。
這是一個螢屏截圖:

uj5u.com熱心網友回復:
你從哪里運行代碼?CSV 檔案是否與您的 python 檔案位于同一目錄中,如果是,控制臺路徑是否與 python 腳本和 CSV 檔案相同?
uj5u.com熱心網友回復:
檢查os.getcwd()您當前的作業目錄是否與檔案路徑匹配
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/495897.html
標籤:Python CSV jupyter-笔记本
上一篇:如何讀取特定資料并寫入csv檔案
