import ospath = '/home/user/project'
filename = 'example'
annopath = os.path.join(path, "Annotations", "{}.xml")xml_path = annopath.format(filename)
print(xml_path)
结果:
/home/user/project\Annotations\example.xml
例2:
x="{:s}xxx"
y=x.format('888')
print(y)
结果
888xxx
