我想保存文件名,我的文件名应该是这样的"doc00012dsadfile5.jpg">
filename = "doc00012dsad.pdf"
mypath = "/desktop/myfolder/"
_path = os.path.join(mypath,"images")
num = 5
#filename.split(".pdf",1)[0]
os.path.join(_path, file%d.jpg" % num), xx)
filename = "doc00012dsad.pdf"
mypath = "/desktop/myfolder/"
_path = os.path.join(mypath,"images")
num = 5
#filename.split(".pdf",1)[0]
os.path.join(_path, "file{}.jpg".format(num), xx)
我不知道xx是什么,但我只是把它放在那里,因为它在你的代码中
在加入前注入,避免混淆
import os
filename = "doc00012dsad.pdf"
mypath = "/desktop/myfolder/"
_path = os.path.join(mypath,"images")
num = 5
file ="file"
f_name = os.path.splitext(filename)[0]
filename = f'{f_name}{file}{num}.jpg'
final = os.path.join(_path,filename)
最终路径
/desktop/myfolder/images/doc00012dsadfile5.jpg