0

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
asked Sep 3, 2020 at 8:35
2
  • 1
    os.system(f'start chrome "{URL1}" --incognito --window-position=-10,-3 --window-size=550,1030') Commented 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? Commented Sep 3, 2020 at 13:47

3 Answers 3

4

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')
Nam G VU
35.8k79 gold badges248 silver badges400 bronze badges
answered Sep 3, 2020 at 8:38
Sign up to request clarification or add additional context in comments.

Comments

3

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))
answered Sep 3, 2020 at 8:43

Comments

2

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
answered Sep 3, 2020 at 8:40

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.