随笔分类 -  Python.函数

摘要:https://www.runoob.com/python/att-string-format.html Python2.6 开始,新增了一种格式化字符串的函数 str.format(),它增强了字符串格式化的功能。 基本语法是通过 {} 和 : 来代替以前的 % 。 format 函数可以接受不限 阅读全文
posted @ 2019-11-04 08:46 逆火狂飙 阅读(208) 评论(0) 推荐(0) 编辑
摘要:常用代码,单拎出来以备查。 对象存json文件: import json obj={'name':'张有财','age':39,'arr':[2,34,5,6,7,88,'李有钱']} with open('./obj.json','w',encoding='utf-8') as fObj: jso 阅读全文
posted @ 2018-05-13 14:43 逆火狂飙 阅读(1434) 评论(0) 推荐(0) 编辑
摘要:代码: # bytes转字符串方式一 b=b'\xe9\x80\x86\xe7\x81\xab' string=str(b,'utf-8') print(string) # bytes转字符串方式二 b=b'\xe9\x80\x86\xe7\x81\xab' string=b.decode() # 阅读全文
posted @ 2018-05-08 18:04 逆火狂飙 阅读(51858) 评论(0) 推荐(0) 编辑
摘要:# 例子: target='www.163.com' print(target.find('163')) if target.find('263') 1: print('263不存在于字符串'+target+'中') 运行: C:\Users\horn1\Desktop\python\7>pytho 阅读全文
posted @ 2018-03-29 17:16 逆火狂飙 阅读(3309) 评论(0) 推荐(0) 编辑

生当作人杰 死亦为鬼雄 至今思项羽 不肯过江东
点击右上角即可分享
微信分享提示