六种数据类型

六大数据类型:

  数值类型:int, float, bool, complex    number不可变

  序列类型: list (可变),  str, tuple   

  非序列类型:set(可变), dict(可变)

变量三属性:

a =1  

  值,地址id,类型type
list插值3种
list1 + list2
li = [1,2,3]
li.append('hello')  [1, 2, 'hello']
li.extend('hello')  [1,2,3,'h','e','l','l','o']

字符串方法

S='afafa23rw'

S.endswith(suffix[, start[, end]]) -> bool
S.startswith(prefix[, start[, end]]) -> bool
S.isalpha() -> bool  字母
S.isdigit() -> bool  数字
S.islower() -> bool  小写

s ='hello python !'
s.split()    ->['hello','python','!']

字符串拼接

'{x}{x}{x}'.format(x='s',y='t',z='r')    ->  'sss'

%s str() 展示给人看的 str('a')
%r repr() 展示给计算机看的 repr('a')
%d digit
%f float()

原文地址:https://www.cnblogs.com/tangpg/p/8668411.html