为什么python不在所有adb语句之后添加双引号?

为什么python不在所有adb语句之后添加双引号?,python,python-3.x,Python,Python 3.x,为什么不在所有adb语句的末尾添加双引号和>CON,而只在最后一个语句中添加?如何修复它?请尝试下面的代码。这将把列表中的每个元素添加到给定字符串中 com.google.android.apps.docs adb shell "pm uninstall --user 0 com.google.android.apps.maps adb shell "pm uninstall --user 0 com.google.android.apps.photos adb

为什么不在所有adb语句的末尾添加双引号和>CON,而只在最后一个语句中添加?如何修复它?

请尝试下面的代码。这将把列表中的每个元素添加到给定字符串中

com.google.android.apps.docs

 adb shell "pm uninstall --user 0 com.google.android.apps.maps

 adb shell "pm uninstall --user 0 com.google.android.apps.photos

 adb shell "pm uninstall --user 0 com.google.android.apps.tachyon

 adb shell "pm uninstall --user 0 com.google.android.feedback

 adb shell "pm uninstall --user 0 com.google.android.gms

 adb shell "pm uninstall --user 0 com.google.android.gms.location.history

 adb shell "pm uninstall --user 0 com.google.android.googlequicksearchbox

 adb shell "pm uninstall --user 0 com.google.android.inputmethod.latin

 adb shell "pm uninstall --user 0 com.google.android.marvin.talkback

 adb shell "pm uninstall --user 0 com.google.android.music

 adb shell "pm uninstall --user 0 com.google.android.printservice.recommendation

 adb shell "pm uninstall --user 0 com.google.android.syncadapters.calendar

 adb shell "pm uninstall --user 0 com.google.android.tts

 adb shell "pm uninstall --user 0 com.google.android.videos

 adb shell "pm uninstall --user 0 com.google.android.youtube

 adb shell "pm uninstall --user 0 com.google.ar.lens

 adb shell "pm uninstall --user 0 com.android.vending

 adb shell "pm uninstall --user 0 com.google.android.gsf" > CON


** Process exited - Return Code: 0 **
Press Enter to exit terminal
为什么使用
.join()
??您可以简单地使用
+“某些字符串”+
对于这种情况,最好使用
+

list = ['com.google.android.apps.docs','com.google.android.apps.maps','com.google.android.apps.photos','com.google.android.apps.tachyon','com.google.android.feedback','com.google.android.gms','com.google.android.gms.location.history','com.google.android.googlequicksearchbox','com.google.android.inputmethod.latin','com.google.android.marvin.talkback','com.google.android.music','com.google.android.printservice.recommendation','com.google.android.syncadapters.calendar','com.google.android.tts','com.google.android.videos','com.google.android.youtube','com.google.ar.lens','com.android.vending','com.google.android.gsf']

for ele in list:
    print('\n adb shell "pm uninstall --user 0 %s" > CON'%ele) #string formatting this puts ele in place of %s

(删除了标签shell、android和adb,因为您的问题与POSIX shell、adb或android都不相关。仅仅因为您输出了一个包含adb文本的字符串,并不表示它是adb问题。哦,对不起,我是新来的,所以认为adb标签可能会有所帮助。我会记住这一点。谢谢。
list = ['com.google.android.apps.docs','com.google.android.apps.maps','com.google.android.apps.photos','com.google.android.apps.tachyon','com.google.android.feedback','com.google.android.gms','com.google.android.gms.location.history','com.google.android.googlequicksearchbox','com.google.android.inputmethod.latin','com.google.android.marvin.talkback','com.google.android.music','com.google.android.printservice.recommendation','com.google.android.syncadapters.calendar','com.google.android.tts','com.google.android.videos','com.google.android.youtube','com.google.ar.lens','com.android.vending','com.google.android.gsf']

for ele in list:
    print('\n adb shell "pm uninstall --user 0 %s" > CON'%ele) #string formatting this puts ele in place of %s
myList = ['com.google.android.apps.docs','com.google.android.apps.maps','com.google.android.apps.photos','com.google.android.apps.tachyon','com.google.android.feedback','com.google.android.gms','com.google.android.gms.location.history','com.google.android.googlequicksearchbox','com.google.android.inputmethod.latin','com.google.android.marvin.talkback','com.google.android.music','com.google.android.printservice.recommendation','com.google.android.syncadapters.calendar','com.google.android.tts','com.google.android.videos','com.google.android.youtube','com.google.ar.lens','com.android.vending','com.google.android.gsf']
for i in myList:
    print('\n adb shell "pm uninstall --user 0 ' + i + '" > CON')