\转义
\转义
字符串:用双引号或者单引号引起来的单词。
例:print("hp")则显示”hp“
如:print(hp)则是显示hp所代表的文本
引号:一个字符串里 有双引号就不能再使用双引号 可以使用单引号
如:同时有单引号和双引号时且字符串的引号不能完全括住文本 可以使用\放于文本引号前
例:message4 = 'my name \' is " siki'
\ 转意字符,针对字符串里需要出现单ying
\转义字符 改变意义的字符
不能用数字开头
hp = 100
print(hp)
hp =90
print(hp)
变量的2个用途:1.存储数据 2.数据变化
字符串输出时,可以使用单引号或者双引号进行输出,如果需要在字符串中加入引号,需要交叉使用单双引号进行输出
m3 = 'i "like" you'
print(m3)
m5 = 'my name \'is "siki'
\转译字符
1.单双引号都是字符串结束开始.
2.“\(转义字符)”可以在字符串中屏蔽单双引号
eg:print(“ my name \" is ' houbing”
输出:my name "is' houbing
字符串变量
m = "hello world"
m2 = 'hello world'
m3 = "hello 'like' you"
m4 = 'hello "like" you'
m5 = "hello 'like\" you"
单双引号都可以,如果字符串里面有双引号,就只能用单引号包含字符串。同样道理,字符串里包含单引号,那字符串只能用双引号包含。
若果字符串里边既包含单引号,也包含双引号,如果想用单引号包含,就得在字符串里的单引号前边加一个\(转义字符)。
\转义字符
\n
print() 函数/方法
hp = 100
print(hp)
hp = 90
print(hp)
print("hp")
字符串类型
使用双引号或者单引号引起来,引起来部分是数据内容
第一个引号代表字符串开始,第二个引号代表字符串结尾
\转义字符
m = "Hello World"
m2 = 'Hello World'
m3 = "i "like" you"
报错
m3 = 'i "like" you'
m = "Hello World"
m2 = 'Hello World'
m3 = 'i "like" you'
m4 = "I'm fine"
m5 = 'my name \' is " siki'
m5 = "my name \' is \" siki"
print(m3)
\可以用来表示未结束
转义字符 \ ,放在 ' 或 " 前面
\?/\/\/\\/\/\/\/\//\/\/\/\\\\\\\\\\\\//////////\/////\/\/\/\/\\\/\/\/\/\/\/\/\/\/\/\/\/\\\\\////\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\/\/\/\/\/\//\/\/\/\/\/\/??///\/\/\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\/\/\/\/\/\/\/\/\/\\/\/\/\/\/\/\/\/\/\/\\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\转义字符
变量不能以数字开头
单引号与双引号的用法
\转义字符
字符串类型
m='hellow word'
\转义字符
1.字符串可用单引号或者双引号表示
"hello world" 'hello world'
单引号括起来的只能用单引号,双引号同理
中间有引号干扰的使用反斜杠