前提・実現したいこと
pythonで財務諸表を自動で分析できるようなシステムを作っています。
ボタンを押すと計算してくれる機能を作っている最中にエラーが発生しました。
発生している問題・エラーメッセージ
app.pyのところのtype(int('cash'))にすると'cash'ValueError: invalid literal for int() with base 10: 'cash'このように出ます。
同じところをtype(int(cash))にするとTypeError: unsupported operand type(s) for -: 'str' and 'str'とこのように出ます。
これからどう直していけばいいかわかりません
該当のソースコード
index
.html <ul class="inner-table">損益計算書</ul> <form action="/tab" method="POST"> <label for="">現金及び預金</label> <input class="main" type="number" name='cash' placeholder="千万円"> <label for="">借金</label> <input class="main" type="number" name='loan' placeholder="千万円"> <label for="">現金及び預金</label> <input class="main" type="text" name="user_name" placeholder="千万円"> <label for="">現金及び預金</label> <input class="main" type="text" name="user_name" placeholder="千万円"> </tr> <ul>貸借対照表</ul> <label for="">現金及び預金</label> <input class="main" type="text" name="user_name" placeholder="千万円"> <ul>キャッシュフロー計算書</ul> <input type="submit" value="計算"> </form> <ul>自己資本率</ul>{{ result }} </body>
app
.py @app.route("/tab",methods=["POST"]) def cash_loan_calculations(): if request.method == 'POST': cash= request.form.get('cash') loan= request.form.get('loan') type(int('cash')) type(int('loan')) difference=cash-loan a= cash/difference return render_template("index.html",result=a)
試したこと
以下の記事を参考にしました。
https://gammasoft.jp/support/python-error-str-convert-to-int/
https://blog.pyq.jp/entry/Python_kaiketsu_200106
補足情報(FW/ツールのバージョンなど)
ファイルとディレクトリの配置
pycache
|-app.cpython-39.pyc
images
|-2.png
static
|-design.css
templates
|-howto.html
|-index.html
|-searched.html
|-table.html
|-Registar.html
|-login.html
app.py
search.db
クレスコ財務データ(自動保存済み).csv
FW:flask
言語:Python3.9.7
pandasダウンロード済み
まだ回答がついていません
会員登録して回答してみよう