会员
周边
新闻
博问
闪存
众包
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
即见吊雷,云胡不喜。
九重天外见轩辕,四面八方皆吊雷。
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
20
21
22
23
24
25
26
27
28
29
下一页
2020年8月6日
python os.path.split()和os.path.splitext()
摘要: os.path.split()将路径 path 拆分为一对,即 (head, tail),其中tail 是路径的最后一部分,而head 里是除最后部分外的所有内容。tail 部分不会包含斜杠,如果path以斜杠结尾,则tail 将为空。如果path中没有斜杠, head 将为空 os.path.sp
阅读全文
posted @ 2020-08-06 00:05 轩辕吊雷
阅读(323)
评论(0)
推荐(0)
2020年8月5日
python 去除文件名中的扩展名
摘要: for file in os.listdir(file_path): file_name = os.path.splitext(file)[0]
阅读全文
posted @ 2020-08-05 23:37 轩辕吊雷
阅读(11138)
评论(0)
推荐(2)
python 遍历指定文件夹
摘要: for file in os.listdir(path):执行语句 注:os.listdir(path) 方法用于返回指定的文件夹包含的文件或文件夹的名字的列表。
阅读全文
posted @ 2020-08-05 23:32 轩辕吊雷
阅读(494)
评论(0)
推荐(0)
python shutil.copytree
摘要: 语法: shutil.copytree(src, dst, symlinks=False, ignore=None, copy_function=copy2, ignore_dangling_symlinks=False,dirs_exist_ok=False) 将以 src 为根起点的整个目录树拷
阅读全文
posted @ 2020-08-05 23:19 轩辕吊雷
阅读(7426)
评论(0)
推荐(0)
python shutil.copy
摘要: 语法: shutil.copy(src,dst,*,follow_symlinks=True) 将文件 src 拷贝到文件或目录 dst。src 和 dst 应为字符串。如果 dst 指定了一个目录,文件将使用 src 中 的基准文件名拷贝到 dst。返回新创建文件的路径。 如果follow_sym
阅读全文
posted @ 2020-08-05 23:16 轩辕吊雷
阅读(1570)
评论(0)
推荐(0)
python 内置函数str(),int()用法
摘要: str()将其他类型转化为字符串格式。 info = {'tom': 'cat', 'jerry': 'mouse'} print(type(info)) print(type(str(info))) int()将一个字符串或数字转换为整型。 str = '10' print(type(int(st
阅读全文
posted @ 2020-08-05 22:52 轩辕吊雷
阅读(1030)
评论(0)
推荐(0)
python 获取对象的类型
摘要: tup = ('hello', 1) print(type(tup)) 注:type和instance的区别 type() 不会认为子类是一种父类类型 instance会认为子类是一种父类类型
阅读全文
posted @ 2020-08-05 22:20 轩辕吊雷
阅读(3659)
评论(0)
推荐(0)
python 获取字符串长度
摘要: str = 'hello world' print(len(str))
阅读全文
posted @ 2020-08-05 22:11 轩辕吊雷
阅读(608)
评论(0)
推荐(0)
python 读写文件及文件对象的方法
摘要: 1、读写文件: open() 返回一个file object,最常用的有两个参数:open(filename, mode)。 f = open('workfile', 'w') 第一个参数是包含文件名的字符串。第二个参数是另一个字符串,其中包含一些描述文件使用方式的字符。 mode 可以是 'r' ,
阅读全文
posted @ 2020-08-05 22:04 轩辕吊雷
阅读(1540)
评论(0)
推荐(0)
python for语句
摘要: for语句用于对序列(例如字符串、元组或列表)或其他可迭代对象中的元素进行迭代。 语法: for_stmt ::= "for" target_list "in" expression_list ":" suite ["else" ":" suite] 即 for 元素 in 迭代对象:执行语句 el
阅读全文
posted @ 2020-08-05 16:03 轩辕吊雷
阅读(516)
评论(0)
推荐(0)
上一页
1
···
20
21
22
23
24
25
26
27
28
29
下一页
公告