職種名、職種、給与を入力できるプログラムを作りたいのですが、入力した職種名、職種、給与をファイルに書き込んでデータを保存したいのですが、うまくいきません。
class Job(object):
def __init__(self, jobName = '', jobCategory = '', jobPay = ''):
self.jobName = jobName
self.jobCategory = jobCategory
self.jobPay = jobPay
def getName(self):
self.jobName = input("What is the Job Title: ")
def getCategory(self):
self.jobCategory = input("What is the Job Category: ")
def getPay(self):
self.jobPay = input("What is the Job Pay: ")
def displayJob(self):
print("Job: " + self.jobName)
print("Job Category: " + self.jobCategory)
print("Job Pay: " + self.jobPay)
print()
def Main():
global NewJob
NewJob = Job()
NewJob.getName()
NewJob.getCategory()
NewJob.getPay()
print()
NewJob.displayJob()
myFile = open('newFile.txt', 'w')
myFile.write(NewJob.displayJob())
myFile.close()
Main()