Python语言是一款对缩进非常敏感的语言,给很多初学者带来了困惑,即便是很有经验的python程序员,也可能陷入陷阱当中。最常见的情况是tab和空格的混用会导致错误,或者缩进不对,而这是用肉眼无法分别的。在编译时会出现这样的错IndentationError:expected an indented block说明此处需要缩进,你只要在出现错误的那一行,按空格或Tab(但不能混用)键缩进就行。
String s = null;s += "hello";System.out.println(s);结果为:nullhello原因:先应用String.valueOf 得出s的value值,再通过StringBuilder拼接hello,因此将value与hello进行了拼接;String s = null; s = (new StringBuilder(String.