代码之家  ›  专栏  ›  技术社区  ›  FMc TLP

在Python中,模仿Perl的结束的最佳方法是什么?

  •  22
  • FMc TLP  · 技术社区  · 16 年前

    我认为Python没有Perl的直接等价物,对吗 __END__ ?

    print "Perl...\n";
    
    __END__
    End of code. I can put anything I want here.
    

    我想到的一个想法是使用三重引号的字符串。有没有更好的方法在Python中实现这一点?

    print "Python..."
    
    """
    End of code. I can put anything I want here.
    """
    
    5 回复  |  直到 16 年前