上一页 1 2 3 4 5 6 7 8 9 ··· 53 下一页
摘要: 正文 描述 Python find() 方法从字符串中找出某个子字符串第一个匹配项的索引位置,该方法与 index() 方法一样,只不过如果子字符串不在字符串中不会报异常,而是返回-1。 语法 find() 方法语法: S.find(sub[,start=0[,end=len(S)]]) 参数 su 阅读全文
posted @ 2020-05-26 17:53 tooltime 阅读(2233) 评论(0) 推荐(0) 编辑
摘要: enumerate()是python的内置函数enumerate在字典上是枚举、列举的意思对于一个可迭代的(iterable)/可遍历的对象(如列表、字符串),enumerate将其组成一个索引序列,利用它可以同时获得索引和值enumerate多用于在for循环中得到计数例如对于一个seq,得到: 阅读全文
posted @ 2020-05-26 16:37 tooltime 阅读(788) 评论(0) 推荐(0) 编辑
摘要: #Python3中已取消iteritems()方法 描述 Python 字典 items() 方法以列表形式(并非直接的列表,若要返回列表值还需调用list函数)返回可遍历的(键, 值) 元组数组。 语法 items() 方法语法: D.items() 参数 无。 返回值 以列表形式返回可遍历的(键 阅读全文
posted @ 2020-05-26 16:05 tooltime 阅读(975) 评论(0) 推荐(0) 编辑
摘要: # -*- coding: utf-8 -*- """ @description: xxx @time: 2019/12/22 1:03 @author: baojinlong """ import random import time import datetime import pymysql 阅读全文
posted @ 2020-05-26 15:58 tooltime 阅读(344) 评论(0) 推荐(0) 编辑
摘要: 情况1:在一个目录下面只有文件,没有文件夹,这个时候可以使用os.listdir 在我们的桌面上有一个file目录(文件夹),里面有三个文件 file(dir)| --|test1.txt --|test2.txt --|test3.txt 用下面的程序获得文件的绝对路径: import os pa 阅读全文
posted @ 2020-04-28 17:13 tooltime 阅读(1173) 评论(0) 推荐(0) 编辑
摘要: python3 中采用 in 方法 1 #判断字典中某个键是否存在 2 arr = {"int":"整数","float":"浮点","str":"字符串","list":"列表","tuple":"元组","dict":"字典","set":"集合"} 3 #使用 in 方法 4 if "int" 阅读全文
posted @ 2020-04-27 19:20 tooltime 阅读(5175) 评论(0) 推荐(0) 编辑
摘要: #创建一个空字典 empty_dict = dict() print(empty_dict) #用**kwargs可变参数传入关键字创建字典 a = dict(one=1,two=2,three=3) print(a) #传入可迭代对象 b = dict(zip(['one','two','thre 阅读全文
posted @ 2020-04-27 19:17 tooltime 阅读(828) 评论(0) 推荐(0) 编辑
摘要: 一下文件执行将产生乱码,切.log文件显示问好,打不开 import logging def shop_logging(name): name = name+"登录成功!" logger = logging.getLogger() fh = logging.FileHandler("test.log 阅读全文
posted @ 2020-04-27 19:13 tooltime 阅读(1061) 评论(0) 推荐(0) 编辑
摘要: 问题解决方法: 阅读全文
posted @ 2020-04-27 18:14 tooltime 阅读(949) 评论(0) 推荐(0) 编辑
摘要: 很多人认为python中的字典是无序的,因为它是按照hash来存储的,但是python中有个模块collections(英文,收集、集合),里面自带了一个子类 OrderedDict,实现了对字典对象中元素的排序。请看下面的实例: import collections print "Regular 阅读全文
posted @ 2020-04-26 14:58 tooltime 阅读(2832) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 53 下一页