数据小注意

数据类型注意

print(type((1,)))#定义元组 加逗号 ;

b="".join([‘a’, ‘b’, ‘c’, ‘d’, ‘e’])# 列表转换为字符串;

ourlist.append([1,2,3]) #直接追加到列表中将列表作为元素;

fucklist=[1,2,“k”,6,7]
fucklist.extend(“123”)#依次加入到列表中排序 打碎加入;

fucklist.insert(4,“L”)#在列表索引4处插入;

b=fucklist.pop(3) print(b)# 指定某数弹出;

yourdict={}.fromkeys(“abcdef”)
print(yourdict) 返回键为打碎的字符,值为None;

#zip 将几个序列对应索引位上的元素分到一个元组当中,总的形成一个列表,子元组的个数取决于提供序列的最小长度,
Zip=zip(“abcdefg”,“12345”)#python2返回对象 python返回对象内存地址 需要用列表进行转换;

fucklist=dict(zip(“abcdefg”,“12345”))#用zip打包并进行制字典 print(fucklist);

ourdict={“a”:1,“b”:3,“c”:7,“d”:10,“g”:8}
ourdict.pop(“b”)#弹出指定键值;

ourdict.update({“h”:18})#对字典添加更新;

ourdict.setdefault(“y”)#创建新键 其值为none
print(ourdict.items())#返回字典键值呈元组形式的格式

#字符串修饰方法
print(“while”.center(10))
print(“while”.center(10,“x”))
print(“while”.ljust(10,“x”))
print(“while”.rjust(10,“x”))
print(“3”.zfill(5))
print(“30”.zfill(5))
print(" while “.strip()) #去掉单词两边空格
print(” while ".rstrip()) #去掉单词右边边空格

.endswith(“a”)) #判断字符串是否以某个字符结尾
.startswith(“h”) #判断是否以某个字符开始;

print(" hello world wha\tt a fucking world ".expandtabs(10)) #修改tab的长度;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值