我已经为simulateBeamRun编写了代码,当我运行它时,它会说我有一个语法

2024-09-27 09:22:27 发布

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

import beamModel
import personModel


def createPersonList(fileName):
    """Function will go through each line of file and
    create a person object using the data provided in
    the line and add it to a list
    """
    theFile = open(fileName)
    next(theFile)

    for line in theFile:
        aList = line.split(',')
        bList = map(lambda s: s.strip('\n'), aList)
        cList = [float(i) for i in bList]
    return cList


def simulateBeamRun(personList, beam, times):
    """Takes a list of times covering the duration of
    the simulation (0-35 s), the list of person
    objects and a beam object to simulate a beam run
    """
    ps = personList
    b = beam
    ts = times

    dList = []
    for time in ts:
        eList = []
    if ps is None:
        return "No values in personList"
    else:
        for person in ps:
            loadTuples = personModel.person.loadDisplacement(time)
            if beamModel.b.L > loadTuples[1] > 0:
                eList.append(loadTuples)
            else:
                return None
        beamModel.b.setLoads(eList)
        dList.append(beamModel.b.getMaxDeflection())
    return (dList, eList)

这是我创建的代码,当我运行它时,在IPython控制台中输入时,我得到语法错误:

b = beamModel.beam(8.0E9, 1.333E-4, 5.0)

ps = createPersonList("personData.csv")

ts = numpy.linspace(0,35,500)

print simulateBeamRun(personList, beam, times)
  File "<ipython-input-18-63875d960559>", line 1
    print simulateBeamRun(personList, beam, times)
                        ^
SyntaxError: invalid syntax

Tags: andoftheinforreturnlinelist

热门问题