【问题标题】:file not found error while using read_csv on a Jupyter notebook在 Jupyter 笔记本上使用 read_csv 时找不到文件错误
【发布时间】:2021-09-14 07:28:45
【问题描述】:

在 Jupyter 笔记本上使用 read_csv() 函数时,即使我列出了确切的路径,我也会收到文件未找到错误。关于为什么会发生这种情况的任何指示?谷歌搜索,一种解决方案是在路径前加上“r”,这很有效。但是为什么需要这个前缀呢?

【问题讨论】:

标签: python jupyter


【解决方案1】:

这是原始字符串事件。当路径包含反斜杠时,在 Windows 操作系统上是必需的。否则,反斜杠将被视为转义字符。例如,"hello\nworld" -- \n 表示换行符。 r"hello\nworld"字面意思是字符"hello\nworld",这样我们就可以在屏幕上看到 hello world

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-09-16
    • 1970-01-01
    • 2020-04-07
    • 1970-01-01
    • 1970-01-01
    • 2020-10-12
    • 2021-09-25
    • 2017-12-21
    相关资源
    最近更新 更多