python一行写不下,变多行

python里一行写不下,拆成多行,

\和() 两种方法

 

在一行末尾 加上“ \”,也就是空格加上\

  a= 'sdfaf' \
     'test'

注意两个对象都要独立,字符串必须都用双引号引起。

如果是if and 后加“ \”。

其实用括号也可以,比如

a=('sdfaf'
'test')

或者

if (xxxx is None and

 xxx is None and

 XXX)

这样做效果是一样的。

 

转载于:https://www.cnblogs.com/cl1024cl/p/6205633.html