【问题标题】:Difference between "." and "./" and "./." for path [closed]“。”之间的区别和“./”和“./.”对于路径[关闭]
【发布时间】:2019-12-14 09:08:00
【问题描述】:

我试过 ls '.'、ls './' 和 ls './.' ,并且它们都给了我相同的结果。

但是对于某个文件,我只能使用“python file ./”而不是其他两个选项来运行它。所以我想知道它们之间有什么区别。

编辑:

这不是我写的。

try:
    in_dir = sys.argv[1]
except:
    sys.exit("Usage: python formatter_oocl.py path/to/dir")

in_dir = "OOCL_RAW_DATA/" # name of directory where xls files will be read from
files = os.listdir("./"+in_dir)
#files = ['./' + in_dir + files[i] for i in range(len(files))]
print(files)

谢谢

【问题讨论】:

  • 不同之处在于您的程序我们无权访问。
  • 一个疯狂的猜测是你的程序假设它可以接受路径参数并直接将文件名连接到它上面。这仅在路径参数为空或以 / 结尾时才有效。

标签: python linux terminal git-bash


【解决方案1】:

. 是您的当前文件夹。之后的/ 仅指定它是一个文件夹,并允许您在之后指定其他文件夹/文件(例如myfolder/myfile 所以 ./.current directory/current directory

据我所知,没有区别……

./yourfile 执行您的文件(如果这是您的要求)

【讨论】:

  • 如果您在原始问题的上下文中提供了解决方案示例,将会很有帮助 - 这也将使其他人更容易理解您的解决方案。
【解决方案2】:

., ./ and ./.都是指当前目录。你使用./file.ext 来运行一个可执行文件。

【讨论】:

    猜你喜欢
    • 2018-06-17
    • 1970-01-01
    • 2014-10-19
    • 2014-09-25
    • 2013-04-25
    • 2015-12-18
    • 1970-01-01
    • 2013-01-04
    • 1970-01-01
    相关资源
    最近更新 更多