python循环列表中的参数并与变量对接

data = '/Users/xxx/Desktop/pycharm/all/'

name_list = ["server_hostname", "cpucore", "cpumodel", "mem", "bond0", "cluster", "os", "net"]
long = len(name_list)
for i in range(long):
    filename = name_list[i]
    mulu = data + filename
    print(mulu)

结果:
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/m0_51777056/article/details/129772550