小甲鱼教学笔记——文件系统
程序员文章站
2024-01-25 21:41:41
...
os模块
import os
os.getcwd()
'C:\\Users\\samsung\\Machine Learning\\初心'
os.listdir('C:\\Users\\samsung\\Machine Learning\\初心')
['.ipynb_checkpoints',
'6.30.ipynb',
'7.7.ipynb',
'boy_1.txt',
'boy_2.txt',
'boy_3.txt',
'girl1.txt',
'girl2.txt',
'girl3.txt',
'Hello Machine Learning.ipynb',
'LinearRegression.py',
'Machine Learning 2.ipynb',
'metrics.py',
'SimpleLinearRegression.py',
'SimpleLinearRegression向量化.ipynb',
'SKNN.py',
'Untitled.ipynb',
'Untitled1.ipynb',
'Untitled2.ipynb',
'__pycache__',
'关于线性回归算法的思考.ipynb',
'实例1.ipynb',
'实现多元线性回归模型.ipynb',
'小甲鱼教学.ipynb',
'小甲鱼教学——元组、字符串.ipynb',
'小甲鱼教学——函数.ipynb',
'小甲鱼教学——列表:常用·操作符.ipynb',
'小甲鱼教学——字典、集合.ipynb',
'小甲鱼教学——字符串:格式化.ipynb',
'小甲鱼教学——序列.ipynb',
'小甲鱼教学——文件.ipynb',
'数据归一化.ipynb',
'梯度模拟下降法.ipynb',
'简单线性回归.ipynb',
'衡量回归算法的标准.ipynb']
os.mkdir('E:\\A')
os.mkdir('E:\\A\\B')
os.remove('E:\\A\\B\\test.txt')
os.rmdir('E:\\A\\B')
os.system('cmd')
0
os.system('calc')
0
os.curdir
'.'
os.listdir(os.curdir)
['.ipynb_checkpoints',
'6.30.ipynb',
'7.7.ipynb',
'boy_1.txt',
'boy_2.txt',
'boy_3.txt',
'girl1.txt',
'girl2.txt',
'girl3.txt',
'Hello Machine Learning.ipynb',
'LinearRegression.py',
'Machine Learning 2.ipynb',
'metrics.py',
'SimpleLinearRegression.py',
'SimpleLinearRegression向量化.ipynb',
'SKNN.py',
'Untitled.ipynb',
'Untitled1.ipynb',
'Untitled2.ipynb',
'__pycache__',
'关于线性回归算法的思考.ipynb',
'实例1.ipynb',
'实现多元线性回归模型.ipynb',
'小甲鱼教学.ipynb',
'小甲鱼教学——元组、字符串.ipynb',
'小甲鱼教学——函数.ipynb',
'小甲鱼教学——列表:常用·操作符.ipynb',
'小甲鱼教学——字典、集合.ipynb',
'小甲鱼教学——字符串:格式化.ipynb',
'小甲鱼教学——序列.ipynb',
'小甲鱼教学——文件.ipynb',
'数据归一化.ipynb',
'梯度模拟下降法.ipynb',
'简单线性回归.ipynb',
'衡量回归算法的标准.ipynb']
os.path模块
os.path.basename('E:\\A:\\B:\\sex.avi')
'sex.avi'
os.path.dirname('E:\\A:\\B:\\sex.avi')
'E:\\A:\\B:'
os.path.join('A','B','C')
'A\\B\\C'
os.path.join('E:\\','A','B','C')
'E:\\A\\B\\C'
os.path.split('E:\\A:\\B:\\sex.avi')
('E:\\A:\\B:', 'sex.avi')
os.path.splitext('E:\\A:\\B:\\sex.avi')
('E:\\A:\\B:\\sex', '.avi')
os.path.getatime('C:\\Users\\samsung\\Machine Learning\\初心\\小甲鱼教学.ipynb')
1596963318.5729034
import time
time.gmtime(os.path.getatime('C:\\Users\\samsung\\Machine Learning\\初心\\小甲鱼教学.ipynb'))
time.struct_time(tm_year=2020, tm_mon=8, tm_mday=9, tm_hour=8, tm_min=55, tm_sec=18, tm_wday=6, tm_yday=222, tm_isdst=0)
time.localtime(os.path.getatime('C:\\Users\\samsung\\Machine Learning\\初心\\小甲鱼教学.ipynb'))
time.struct_time(tm_year=2020, tm_mon=8, tm_mday=9, tm_hour=16, tm_min=55, tm_sec=18, tm_wday=6, tm_yday=222, tm_isdst=0)
time.localtime(os.path.getctime('C:\\Users\\samsung\\Machine Learning\\初心\\小甲鱼教学.ipynb'))
time.struct_time(tm_year=2020, tm_mon=6, tm_mday=10, tm_hour=15, tm_min=21, tm_sec=27, tm_wday=2, tm_yday=162, tm_isdst=0)
time.localtime(os.path.getmtime('C:\\Users\\samsung\\Machine Learning\\初心\\小甲鱼教学.ipynb'))
time.struct_time(tm_year=2020, tm_mon=8, tm_mday=9, tm_hour=16, tm_min=55, tm_sec=18, tm_wday=6, tm_yday=222, tm_isdst=0)
上一篇: 全面解析不一样的python线程
下一篇: js的异步请求出现同步效果