简体   繁体   中英

How do I run every string in a list in python? (os.startfile)

I want to run every file in a list with os.startfile() but I have no clue how to do it and haven't messed with arrays much. I've tried 'os.startfile(list)' but that doesn't seem to work. Does anyone know how?

List example:

list = ['C:\Programme Files\example1.exe', 'C:\Programme Files\example2.exe', 'C:\Programme Files\example3.exe', ]
for path in list:
    os.startfile(path)

Also, you might want to change 'list' to a different name, because IDE's usually highlight the word list, which makes it look weird.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM