python中一般是一行寫(xiě)完所有代碼,如果遇到一行寫(xiě)不完需要換行的情況,有兩種方法:
1.在該行代碼末尾加上續(xù)行符“\”(即空格+\);
test='item_one'\
'item_two'\
'tem_three'
輸出結(jié)果:
'item_oneitem_twotem_three'
2.加上括號(hào),(){}[]中不需要特別加換行符:
test2=('csdn'
'cssdn')
輸出結(jié)果:
csdncssdn
if...and:
if(wherethereisawilland
thereisaway)