我有以下几种路径:
"/home/path1"
"/home/path2"
"/home/path3"
....
如何用一个变量表示所有变量?
喜欢:"/home/path[x]"
?
答案 0 :(得分:0)
如果我理解正确,可能有两种方法:
for x in range(0,100): path = "/home/path{}".format(i) print(path)
paths = ['path1', 'path2', 'path3'] for x in paths: path = "/home/{}".format(x) print(path)