gpt4 book ai didi

Python2.7 ~波浪号在路径中无法识别为主目录 macOs

转载 作者:行者123 更新时间:2023-11-28 20:57:15 26 4
gpt4 key购买 nike

<分区>

在某些时候波浪符号 ~ 不再被识别为我的主目录,仅在 Python 中。 ~ 仍然可以在终端中使用,所以我不确定发生了什么但是任何关于如何修复它的见解你都会节省我一些打字谢谢!

在 macOS Mojave 上

import os
tilde = '~'
print(os.path.exists(tilde))
os.system("if test -d ~; then echo 'exists'; fi")

输出:

False
exists

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