タイトルに有るとおり、 E402 module level import not at top of fileのエラーを解決したいです。
一つ目のコードを2つ目のコードのように修正したいですが、SQLAlchemyをimportしてからdb変数に格納してそれ以降のimport先でdbを読み込むことができなくなります。どう解決していけばよいか迷っています。
PEP8に沿わない書き方
flask
1from flask_sqlalchemy import SQLAlchemy 2 3db = SQLAlchemy() 4 5from url.test import test 6from url.test1 import test1 7
こういうふうに並べ返したい。PEP8に沿うが、エラーがでてしまう。
flask
1db = SQLAlchemy() 2from flask_sqlalchemy import SQLAlchemy 3from url.test import test 4from url.test1 import test1 5

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。