小编zds*_*_cn的帖子

在python中,如果函数没有return语句,它返回什么?

鉴于此示例函数:

def writeFile(listLine,fileName):
    '''put a list of str-line into a file named fileName'''
    with open(fileName,'a',encoding = 'utf-8') as f:
        for line in listLine:
            f.writelines(line+'\r\n')
    return True
Run Code Online (Sandbox Code Playgroud)

这个return True陈述有用吗?

它和没有它有什么区别?如果没有返回功能会发生什么?

python python-3.x

16
推荐指数
1
解决办法
2万
查看次数

标签 统计

python ×1

python-3.x ×1