python的数与字符串
数的类型:
>>符号整数型(int):0、1、-1
>>长整型(long):88888888、999999999
>>浮点型(float):2.77777、3.4445544
>>布尔型(bool):True、False
>>复数型(complex):4+2j、-9+20j
字符串:
>>在python中用引号引起来的字符集称之为字符串,比如"Hello"、'python'、“234”
>>> a = '234'
>>> print (a)
234
>>> b = 'It is "234"'
>>> print(b)
It is "234"
>>单引号与双引号可交叉使用
>>> a = "It is \"234\""
>>> print(a)
It is "234"
>>如不交叉使用,引入转移符\
>>> a = '''afdafadsfafdafdsafs
fadfdafasdfdasfasd
fdafdasfdasfdsaf
fadfsadfdsafsad'''
>>> print (a)
afdafadsfafdafdsafs
fadfdafasdfdasfasd
fdafdasfdasfdsaf
fadfsadfdsafsad
>>> b = """afdafadsfafdafdsafs
fadfdafasdfdasfasd
fdafdasfdasfdsaf
fadfsadfdsafsad"""
>>> print(b)
afdafadsfafdafdsafs
fadfdafasdfdasfasd
fdafdasfdasfdsaf
fadfsadfdsafsad
>>三引号可换行
>>> print('hello python\n'*5)
hello python
hello python
hello python
hello python
hello python
>>输出多次字符串
>>字符串运算
>>> a = 'hello python'
>>> a[0]
'h'
>>> a[-1]
'n'
>>> a[:2]
'he'
>>> a[2:]
'llo python'
>>> a[5:]
' python'
>>字符串的拼接
>>> print('abc'+'def') abcdef