Python: Python 3.6
I have this code, to create a directory for the year, and a directory in that directory.
def create_dir(year_exists, month_exists):
year_exists=os.path.isdir((str(datetime.datetime.now().year))
if year_exists==true:
os.chdir(str(datetime.datetime.now().year))
else:
os.mkdir(str(datetime.datetime.now().year))
os.chdir(str(datetime.datetime.now().year))
month_exists=os.path.isdir((str(datetime.datetime.now().month))
if month_exists==true:
os.chdir(str(datetime.datetime.now().month))
else:
os.mkdir(str(datetime.datetime.now().month))
os.chdir(str(datetime.datetime.now().month))
And yes, I did import datetime and os.
However, when I run the code, I get
File "C:\Users\[username]\Desktop\python projects\Python-Stats-Finder\finder.py", line 29
if year_exists==true:
^
SyntaxError: invalid syntax
What did I do wrong with my code to generate the syntax error, even if the syntax is correct (I checked)?
Aucun commentaire:
Enregistrer un commentaire