gpt4 book ai didi

python - os.path.join() 只接受一个参数(给定 2 个)

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

我收到 python 错误:TypeError: join() takes exactly one argument (2 given) 在 set_Xpress 方法的第 139 行,看起来像这样:

from os import path
from json import load
...
def set_Xpress(Xpress_number, special_ts, disk, platform, testcase):
...
with open("{0}:\\BBT2\\Configuration\\temporary.tmp".format(disk), "r") as test_conf_file_r:
test_conf_vocab = load(test_conf_file_r)
report = path.join(test_conf_vocab["report_dir"], test_conf_vocab["report_name"])
...

请帮助我了解是什么原因造成的。 Python shell 可以毫无问题地执行它,并且使用此 tmp 文件在另一种方法中可以很好地执行相同的笔画。提前致谢。

最佳答案

path 不是 os.path 模块,它是一个字符串。你在某处重新定义了它。

from os import path  # path is a module, path.join takes many arguments

...

path = '/some/path' # path is now a string, path.join is a totally
# different method, takes a single iterable
...

report = path.join(one, two) # TypeError, str.join takes one argument

关于python - os.path.join() 只接受一个参数(给定 2 个),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16236435/

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