python一行写不下,变多行

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

\和() 两种方法

 

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

  a= 'sdfaf' \
     'test'

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

如果是if and 后加“ \”。

其实用括号也可以,比如

a=('sdfaf'
'test')

或者

if (xxxx is None and

 xxx is None and

 XXX)

这样做效果是一样的。

 

posted on 2013-08-08 17:09  代码王子  阅读(1606)  评论(0编辑  收藏  举报

导航