[英]String Manipulating and slicing from a list
import os
a = ['docs-assets', 'ico', 'favicon.png']
for item in range(len(a)):
z = os.path.join("sample",a[item])
print(z)
Results: 结果:
sample\docs-assets
sample\ico
sample\favicon.png
Can you tell me how i can join each item in the "a" list using os.path.join() so that the result would be: 您能告诉我如何使用os.path.join()加入“ a”列表中的每个项目,以便结果是:
sample\docs-assets\ico\favicon.png
Thanks 谢谢
os.path.join('sample', *a)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.