pythonで別クラスの関数を実行しています。
python test2.pyを実行した際に、標準出力に"keiがおかしいよ"と出力されます。
python
1##test1.py## 2class keisan(): 3 def tasu(self, x, y): 4 kei = x + y 5 try: 6 print(key) 7 except: 8 print("keiがおかしいよ") 9 raise
python
1##test2.py## 2from test1 import keisan 3 4q = keisan() 5try: 6 q.tasu(1,3) 7except: 8 pass
新たにtest3.pyファイルを作りました。
実現したいことはtest3.pyのcontentにtest1.pyのraiseの内容を入れて、出力させたいです。
python
1##test3.py## 2from test1 import keisan 3 4q = keisan() 5try: 6 q.tasu(1,3) 7except: 8 content = ("ここにtest1.pyが出力する値を入れたい") 9 print(content)
変な質問かもしれませんが、ご教示お願い致します。
以上何卒宜しくお願い致します
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/05/01 09:54
2018/05/01 09:56
2018/05/01 09:58