**第110行,in<module>TypeError:不支持+:'int'和'str'的操作数类型

2024-06-17 07:55:03 发布

您现在位置:Python中文网/ 问答频道 /正文

所以,公司里有人走了,我拿到了这个剧本(我们真的需要工作)。我这辈子从没计划过一天

在google和YouTube上搜索了一番之后,我明白了问题是在代码的某个地方,它试图使用+一个整数和一个字符串串在一起(这是不允许的)。但是,我不知道这个错误发生在哪里。我知道上面写的是第110行,下面是第108-125行,是不是(account+'---'+“ELP CAC Config Selected”)有问题

 if stage == 'CAC':
        if fund == 'ELP':
            logNotes(account + ' --- ' + ' ELP CAC Config Selected')
            fileTypes = ['ConsumerAgreement', 'HCOCAC', 'HCODAC']
        elif fund == 'KW':
            logNotes(account + ' --- ' + ' KW CAC Config Selected')
            fileTypes = ['ConsumerAgreement', 'CAC', 'HCOCAC', 'HCODAC']
    elif stage == 'IC':
        logNotes(account + ' --- ' + ' General IC Config Selected')
        fileTypes = ['BuildingPlans', 'SystemPhotos', 'InstallationCompletionCertificate', 'HCOIC']
    elif stage == 'FA':
        if fund == 'Investec':
            logNotes(account + ' --- ' + ' Investec Config Selected')
            fileTypes = ['BOS', 'ConsumerAgreement', 'ConditionalWaiverIC','Conditional WaiverFA']
            fund = 'KW'
        else:
            logNotes(account + ' --- ' + ' General FA Config Selected')
            fileTypes = ['FinalAcceptanceCertificate', 'PTO']

Tags: configifaccountstageselectedelifkwfiletypes
1条回答
网友
1楼 · 发布于 2024-06-17 07:55:03

在Python中,不能“添加”数字和字符串。因此,必须首先将数字转换为其字符表示形式。 尝试用以下代码替换代码:

 account_str = str(account)  # Save the converted account string

 if stage == 'CAC':
    if fund == 'ELP':
        logNotes(account_str + '  - ' + ' ELP CAC Config Selected')
        fileTypes = ['ConsumerAgreement', 'HCOCAC', 'HCODAC']
    elif fund == 'KW':
        logNotes(account_str + '  - ' + ' KW CAC Config Selected')
        fileTypes = ['ConsumerAgreement', 'CAC', 'HCOCAC', 'HCODAC']
elif stage == 'IC':
    logNotes(account_str + '  - ' + ' General IC Config Selected')
    fileTypes = ['BuildingPlans', 'SystemPhotos', 'InstallationCompletionCertificate', 'HCOIC']
elif stage == 'FA':
    if fund == 'Investec':
        logNotes(account_str + '  - ' + ' Investec Config Selected')
        fileTypes = ['BOS', 'ConsumerAgreement', 'ConditionalWaiverIC','Conditional WaiverFA']
        fund = 'KW'
    else:
        logNotes(account_str + '  - ' + ' General FA Config Selected')
        fileTypes = ['FinalAcceptanceCertificate', 'PTO']

相关问题 更多 >