python一行写不下,变多行

https://blog.csdn.net/longshenlmj/article/details/9838377

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

\和() 两种方法

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

  a= 'sdfaf' \
     'test'

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

如果是if and 后加“ \”。

其实用括号也可以,比如

a=('sdfaf' 
'test')

或者

if (xxxx is None and

 xxx is None and

 XXX)

这样做效果是一样的。


猜你喜欢

转载自blog.csdn.net/qq_34638161/article/details/80497498