gpt4 book ai didi

directory - Rebol2:将目录更改为绝对文件路径不起作用

转载 作者:行者123 更新时间:2023-12-02 11:26:29 25 4
gpt4 key购买 nike

我正在尝试从配置文件中读取文件路径,然后从该目录中读取。但我找不到让它工作的方法,因为由于某种原因,change-dir 永远不会进入绝对文件路径。这是我尝试使其在 CLI 上运行的记录。

>> test: pick read/lines %test.ini 1
== "test: C/Users/thompson/Downloads/"
>> test: find test " "
== " C/Users/thompson/Downloads/"
>> test: next test
== "C/Users/thompson/Downloads/"
>> test: to file! test
== %C/Users/thompson/Downloads/
>> change-dir test
** Access Error: Cannot open /C/rscratch/C/Users/thompson/Downloads/
** Near: change-dir test

最佳答案

失败是因为 Rebol 看不到

%C/Users/thompson/Downloads/

作为绝对路径 - 它缺少神奇的前导斜线,因此被视为相对路径。绝对路径是这样的:

%/C/Users/thompson/Downloads/

很容易解决,如果你确定你没有那个前导斜杠:

>> test: pick read/lines %test.ini 1
== "test: C/Users/thompson/Downloads/"
>> test: find test " "
== " C/Users/thompson/Downloads/"
>> test: next test
== "C/Users/thompson/Downloads/"
>> test: to file! join "/" test

关于directory - Rebol2:将目录更改为绝对文件路径不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40223462/

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