更改字符串的特定元素

change specific elements of strings

我有一个商店和 4 个顾客。 lng ,商店的纬度是 50,30,商店列表是:

lng_customers= [51,52,53,54]
lat_customers= [35,36,37,38]

我想使用循环为所有这些字符串制作这些字符串。

'your points are/{50},{30};{51},{35}'  
'your points are/{50},{30};{52},{36}' 
'your points are/{50},{30};{53},{37}' 
'your points are/{50},{30};{54},{38}' 

如何制作这些字符串?请帮助我。

如果您的字符串中需要花括号,这就可以了:

lng_customers = [51, 52, 53, 54]
lat_customers = [35, 36, 37, 38]

string = 'your points are/{{50}},{{30}};{{{}}},{{{}}}'

for lng, lat in zip(lng_customers, lat_customers):
    print(string.format(lng, lat))

如果没有,请执行此操作:

string = 'your points are/50,30;{},{}'

for lng, lat in zip(lng_customers, lat_customers):
    print(string.format(lng, lat))

或者:

string = 'your points are/{},{};{},{}'

for lng, lat in zip(lng_customers, lat_customers):
    print(string.format(50, 30, lng, lat))

这对我有用:

lng_customers= [51,52,53,54]
lat_customers= [35,36,37,38]

for i, j in zip(lng_customers, lat_customers):
    print('your points are/{50},{30}; {%s}, {%s}' % (i, j))
lng_customers = [51, 52, 53, 54]
lat_customers = [35, 36, 37, 38]
lng, lat = 50, 30

for i in range(len(lng_customers)):
    requiredString = "your points are/{" + f"{lng}" + "},{" + f"{lat}" + "};{" + f"{lng_customers[i]}" + "},{" +f"{lat_customers[i]}" + "}"
    print(requiredString) 

#您可以根据需要打印或保存在某个地方