Unicode在Python中转义了注释

Ben*_*and 0 python unicode comments escaping lexical-analysis

我创建了一个Java程序,它使用unicode转义字符来打破多行注释并隐藏一些功能.下面的程序打印出"Hello Cruel World".我想知道在Python(任何版本)中是否可以这样做.如果不可能,这种语言会如何阻止?

public static void main(String[] args) {
    print("Hello");

    /*
     * \u002A\u002F\u0070\u0072\u0069\u006E\u0074\u0028\u0022\u0043\u0072\u0075\u0065\u006C\u0022\u0029\u003B\u002F\u002A
     */
    print("World");
}

private static void print(String s){
    System.out.print(s + " ");
}
Run Code Online (Sandbox Code Playgroud)

请注意,unicode是转义字符串 */print("Cruel");/*

到目前为止我没有成功的尝试......

test = False

#\u0023test = True

'''
\u0027\u0027\u0027
test = True 
\u0027\u0027\u0027
'''

print(test)
Run Code Online (Sandbox Code Playgroud)

Ant*_*ala 5

Python词法分析器仅 Unicode字符串文字中处理Unicode转义(u''在Python 2中,''在Python 3中),因此这种方法是不可能的.

如果你只尝试简单的空间\u0020,python吐出:

SyntaxError: unexpected character after line continuation character
Run Code Online (Sandbox Code Playgroud)

这是因为外部字符串文字,该\字符主要用于将长行分成几个较短的行:

spam = foo + bar + baz + ham + \
       eggs + ham + spam + spam + \
       spam + sausages + spam 
Run Code Online (Sandbox Code Playgroud)

外部字符串,后面唯一允许的字符\是换行符.