python用“\”来连接多行较长的语句

python中较长的语句如果一行写不完可以用“\”来连接多行语句

在(),{},[] 中无需用“\”连接

print('hello world,\
I am \
KangKang')

s = [1,2,3,
	4,5,6,
	7,8,9]
print(s)

运行结果如下

hello world,I am KangKang
[1, 2, 3, 4, 5, 6, 7, 8, 9]

猜你喜欢

转载自blog.csdn.net/baidu_41632451/article/details/81416077
今日推荐