如何在 Django 中声明函数"to do nothing"



我正在学习PythonDjango,我有一个问题。

我想知道如何定义一个不做任何事情的函数,并在我读取存档时继续执行程序的流程。

while True:
     empty()
     with open(r'archive.txt') as myfile:
        for line in myfile:
            print(line)

如何编写一个什么都不做的函数,例如:

def empty(): 

我想这就像在纯python中

def empty():
    pass

如果你正在使用Python 2.x:

def empty():
    pass

使用Python 3。你也可以这样做:

def empty():
    ... # this is called Ellipsis, simply three dots in a row

最新更新