我刚刚遵循了youtube上的一些教程,但是,我正确地遵循了该教程,但对我不起作用。故事是,我试图在timestamp(在MySQL中)属性(即 created_at )中获取月份的名称。希望有人可以帮助我,这将是很大的帮助。
def create_unique_folder(root_dir):
folder_name = str(uuid.uuid4())
dir_path = root_dir + '/' + folder_name
try:
os.mkdir(dir_path)
except Exception as e:
print(e.args)
return None
return folder_name
@app.route('/', methods=['GET', 'POST'])
def upload_file():
if request.method == 'POST':
resp = {}
files = request.files.getlist('files')
print(files)
#print(type(files))
folder_name = UPLOAD_FOLDER + create_unique_folder(app.config['UPLOAD_FOLDER'])
if folder_name != None:
for f in files:
print(folder_name)
file_path = folder_name + '/' + f.filename
f.save(os.path.join(folder_name, f.filename))
file = f
print('inside upload file')
print('file')
filename = f.filename
ffilename = secure_filename(file.filename)
print(filename)
我希望获得像3月,6月,1月这样的月份的名称。但是它有一个错误消息:“试图获取非对象的属性'日期'”
答案 0 :(得分:0)
根据您的评论,由于您以JSON格式存储字符串数组,因此不需要->date
。
$date = new \DateTime($unformattedDate);