Reputation: 89
As captioned, anybody can help me to solve the problem? Many thanks!
from selenium import webdriver
from datetime import datetime
from selenium.webdriver.chrome.options import Options
today = datetime.now()
chrome_options = Options()
chrome_options.add_experimental_option("prefs", {
"download.default_directory": r"C:\Users\XXX\Downloads\ + today.strftime("%Y%m%d")",
"download.prompt_for_download": False,
"download.directory_upgrade": True,
"safebrowsing.enabled": True
})
driver = webdriver.Chrome(options=chrome_options)
I would like to show the result like this:
"C:\Users\XXX\Downloads\20210301"
Upvotes: 0
Views: 116
Reputation: 473
"download.default_directory": r"C:/Users/XXX/Downloads/" + today.strftime("%Y%m%d")
you had an issue in double quote here. Also you should change the lashes
Upvotes: 1