On normal cases string + string works but here I cant get URL1 inside my chrome code.
URL1 = "https://www.google.com/"
os.system('start chrome "url here" --incognito --window-position=-10,-3 --window-size=550,1030')
I've tried doing
os.system('start chrome "%s" --incognito --window-position=-10,-3 --window-size=550,1030') % (URL1)
but it didn't work either.
Any help?
Nam G VU
35.8k79 gold badges248 silver badges400 bronze badges
-
1os.system(f'start chrome "{URL1}" --incognito --window-position=-10,-3 --window-size=550,1030')Janith– Janith2020年09月03日 08:44:50 +00:00Commented Sep 3, 2020 at 8:44
-
Welcome to StackOverflow. What happened when "it didn't work either" ? Did you get an error message? Did nothing happen?rajah9– rajah92020年09月03日 13:47:47 +00:00Commented Sep 3, 2020 at 13:47
3 Answers 3
You can use f-string
Code try it here
import os
URL1 = "https://www.google.com/"
os.system(f'start chrome "{URL1}" --incognito --window-position=-10,-3 --window-size=550,1030')
Sign up to request clarification or add additional context in comments.
Comments
You run os.system and then use tuple with URL1, concat with result
os.system('start chrome "%s" --incognito --window-position=-10,-3 --window-size=550,1030') % (URL1)
Need change to
os.system(('start chrome "%s" --incognito --window-position=-10,-3 --window-size=550,1030') % (URL1))
Comments
You can just try f-string formatting:
os.system(f'start chrome {URL1} --incognito --window-position=-10,-3 --window-size=550,1030')
This will work.
Nam G VU
35.8k79 gold badges248 silver badges400 bronze badges
Comments
lang-py