我有多个字符串需要原始字符串来追加不同的字符串。原始字符串和附加字符串都包含1个int变量根据我的知识,以下两个代码都在工作,但是最好的方法是做什么或者是否有更好的方法来做到这一点? 或者有什么办法,我可以写类似多个字符串与索引一起追加
newstrg = '{}{}'.format(org%OrgInt, appd%appdInt)
第一种方法
org = "org__%s"
appd = "appd__%s"
orgInt = 1
appdInt = 7
newstrg = org % orgInt + appd % appdInt
print(newstrg)
org__1appd__7
方法二
org = "org__{}"
appd = "appd__{}"
orgInt = 1
appdInt = 7
newstrg = (org + appd).format(orgInt, appdInt)
org__1appd__7
更好究竟是什么意思? –
为我的组织和应用程序字符串维护或寻找专业人员 – jacobcan118