歡迎在下方留言、討論、交流
1、AttributeError: 'Request' object has no attribute 'methods'
報錯原因:在進(jìn)行后端邏輯實(shí)現(xiàn)文件上傳時,if request.methods == 'POST' and 'file' in request.files這句話出錯,request只有method方法,沒有methods方法。
2、AttributeError: 'NoneType' object has no attribute 'stdout'
報錯原因:出錯在使用moviepy庫1.0.1版本,目前最好的做法似乎是恢復(fù)到1.0.0版。使用pip install moviepy==1.0.0后即可正常使用。
3、Flask中js文件不生效
app.config['SEND_FILE_MAX_AGE_DEFAULT']=timedelta(seconds=1) #設(shè)置只緩存一秒
4、flask-sqlalchemy向數(shù)據(jù)庫添加一條紀(jì)錄時,如何在commit前獲取該條記錄的id
user=user(
? ? " " "?
? ? 各種數(shù)據(jù)項(xiàng),xx=xx的形式
????" " ")
db.session.add(user)
db.session.flush( ) #在commit前添加這一條語句
db.session.commit()
return user.id
5、url_for()指向靜態(tài)資源時,獲取完整的URL
url_for('static',_external=True,filename='1.mp4')