gpt4 book ai didi

python - 你如何在python中定义本地路径

转载 作者:太空宇宙 更新时间:2023-11-03 12:44:42 31 4
gpt4 key购买 nike

早上好,我可以指出如何在python中进入一个内部硬盘的路径,目前使用语句:

file = GETfile() or 'http://**********'

我想放一个本地文件的路径,但它不起作用,我哪里错了?

file = GETfile() or 'D:\xxx\xxxx\playlist\playlist.m3u'

最佳答案

\ 是转义符。你有三个选择。

1) 使用/。这作为奖励也适用于 linux:

 'D:/xxx/xxxx/playlist/playlist.m3u'

2) 转义反斜杠

 'D:\\xxx\\xxxx\\playlist\\playlist.m3u'

3) 使用原始字符串:

r'D:\xxx\xxxx\playlist\playlist.m3u'

关于python - 你如何在python中定义本地路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42386322/

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