There is a list of file names. I am trying to create a dictionary based on it, so that the key is the time to create the file, and the value is the name of the file.
import os AllFileFull = ['file1.txt', 'file2.txt'] DictTimeFull = {os.path.getmtime(file_name):file_name for file_name in AllFileFull} When the script is run, the interpreter finds a syntax error, although there are no errors in the python 2.7.5 IDE and the code is executed.
# python test-script.py File "test-script.py", line 5 DictTimeFull = {os.path.getmtime(file_name):file_name for file_name in AllFileFull} ^ SyntaxError: invalid syntax The question is how to rewrite this place?