我的最终目标是在运行以下代码时获得[\'2 \',\'3 \']:
results=['2','3']
launchArgs=[]
for thing in results:
thing="'"+thing+"'"
THING=thing.replace("'","\'")
launchArgs.append(THING)
print(launchArgs)
但是,我得到
["\'2\'", "\'3\'"]
我该怎么办?
答案 0 :(得分:0)
“ [\'{} \',\'{} \']”。format(2,3) 我认为您应该将方括号放在“”中,因为我从未见过此[\'\'],仅在字符串“ [\'\']”中