“加入Path”之间的区别和“/&quot”在Pathlib中
JOINPath
与/code>
pathlib
模块中的操作员之间是否存在区别?该文档永远不会比较两种方法。本质上,这两个情况有所不同吗?
例子:
from pathlib import Path
foo = Path("some_path")
foo_bar_operator = foo / "bar"
foo_bar_joinpath = foo.joinpath("bar")
foo_bar_operator == foo_bar_joinpath
# Returns: True
Is there a difference between joinpath
and the /
operator in the pathlib
module? The documentation doesn't ever compare the two methods. Essentially are there any cases where these two are different?
Example:
from pathlib import Path
foo = Path("some_path")
foo_bar_operator = foo / "bar"
foo_bar_joinpath = foo.joinpath("bar")
foo_bar_operator == foo_bar_joinpath
# Returns: True
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有区别。
”将多个参数传递到
joinpath
ega.joinpath(b,c,d)
。/ < / code>的等效词是
a / b / c / d < / code>。
There is no difference. The source code confirms this:
Note you can pass multiple arguments to
joinpath
e.g.a.joinpath(b, c, d)
. The equivalent for/
would bea / b / c / d
.