python学习笔记(2)

Python中变量命名规则:

1、区分大小写

2、变量名必须以字母或下划线字符开头

3、变量名中不能包含空格

 

字符显示:

单引号与双引号在字符串标识中效果一致

Python中“+”可以作为运算符号,也可以作为字符串拼接符号。

如果要显示多行的字符串要使用三重引号如下:

long_string = """Down by the Salley Gardens 走进莎莉花园

My love and I did meet 我和我的爱人相遇

She passed the Salley Gardens 她穿越莎莉花园

With little snow-white feet 踏著雪白的纤足

She bid me take love easy 她请我轻柔的对待这份情

As the leaves grow on the tree 像依偎在树上的群叶"""

print(long_string)

运行结果:

若是使用一个引号

long_string = "Down by the Salley Gardens 走进莎莉花园

My love and I did meet 我和我的爱人相遇

She passed the Salley Gardens 她穿越莎莉花园

With little snow-white feet 踏著雪白的纤足

She bid me take love easy 她请我轻柔的对待这份情

As the leaves grow on the tree 像依偎在树上的群叶"

print(long_string)

 

运行提示:long_string = "Down by the Salley Gardens 走进莎莉花园

                                                    ^

SyntaxError: EOL while scanning string literal在字符串首尾忘记加引号

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值