Python3.6.5でClassを使って計算したものを表示するプログラムを作成し、それをcx_Freezeを使ってexe化しました。
setup.pyでexe化したものを実行するとコマンドプロンプトが一瞬だけ立ち上がり、すぐ閉じてしまいます。
目を凝らしてみたところ、プログラムの表示はしっかりしており、エラーなども表示されません。
教えてください。
setup.py
1# coding: utf-8 2# cx_Freeze 用セットアップファイル 3 4import sys 5import os 6from cx_Freeze import setup, Executable 7 8base = None 9 10# GUI=有効, CUI=無効 にする 11#if sys.platform == 'win32' : base = 'Win32GUI' 12 13 14# セットアップ 15setup( name = "sample", 16version = "1.0", 17description = "converter", 18executables = [Executable("sample.py", base=base)])
sample.py
1 2class Natural(int): 3 def __init__(self,num): 4 self.num = num 5 int.__init__(self) 6 7 def __add__(self, other): 8 return Natural((self.num).__add__(other.num)) 9 10 def __sub__(self, other): 11 if self.num >= other.num: 12 return Natural((self.num).__sub__(other.num)) 13 else: 14 return Natural(0) 15 16 17 def __mul__(self, other): 18 return Natural((self.num).__mul__(other.num)) 19 20 21 def __floordiv__(self, other): 22 return Natural((self.num).__floordiv__(other.num)) 23 24a = Natural(1) 25b = Natural(2) 26print(a+b) 27print(type(a+b)) 28c = Natural(9) 29d = Natural(3) 30print(c//d) 31print(type(c//d))

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