gpt4 book ai didi

python - 路径 "."和 "./"以及 "./."之间的差异

转载 作者:太空宇宙 更新时间:2023-11-04 04:39:29 26 4
gpt4 key购买 nike

我尝试了 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)

谢谢

最佳答案

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

据我所知,没有区别...

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

关于python - 路径 "."和 "./"以及 "./."之间的差异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57382367/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com