I am trying to add a path in this code, how do i do it? I dont understand it.
# folder path
data_folder = Path("Desktop\biologi")
if y == ('biologi'):
document = Document() #create blank document
document.save(y+(x.strftime(" %Y-%m-%d"))+".docx") #save blank document, lägg in path här
document = Document(y+(x.strftime(" %Y-%m-%d"))+".docx") #open document
p = document.add_paragraph()
p.add_run(str(y+(x.strftime(" %Y-%m-%d"))))#edit words
document.save(y+(x.strftime(" %Y-%m-%d"))+".docx")#save edited document
´´´
Use os
library.
import os
DESKTOP_PATH = os.path.expanduser("~\Desktop")
data_folder = os.path.join(DESKTOP_PATH, 'biologi')
print(data_folder)
# prints
# C:\Users\<Username>\Desktop\biologi
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.