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?

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')
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))

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.