一、os平台编程需求

1、目录文件的操作

对系统目录,文件的操作方法

2、程序的定时执行

3、可执行程序的转换

python程序向可执行程序的转换

二、目录文件操作

root:当前目录;

dirs:当前目录下的文件夹

files:当前目录下的文件名

 import os
path =input("路径:")
for root,dirs,files in os.walk(path):
print(root,"\n")
print(dirs,"\n")
print(files,"\n")
 import os
path =input("路径:")
for a in os.walk(path):
print(a[0],"\n")
print(a[1],"\n")
print(a[2],"\n")

以下程序返回绝对路径

 import os
path =input("路径:")
for root,dirs,files in os.walk(path):
for name in files:
print(os.path.join(root,name) 

更改名字,所有名字加了_ok。

 import os
path=input("路径:")
for root,dirs,files in os.walk(path):
for name in files:
fname,fext=os.path.splitext(name)
os.rename(os.path.join(root,name),os.path.join(root,fname+"_ok"+fext))
print(name)

三、定时执行程序

delay:延长多少时间执行

priority:执行优先级

action:执行具体功能

argument:需要的参数

 import sched, time

 def print_time():
print("From print_time", time.time())
def print_some_times():
print (time.time()) s = sched.scheduler(time.time, time.sleep) # 生成调度器
print(time.time())
s.enter(5, 1, print_time, ())
# 加入调度事件
# 四个参数分别是:
# 间隔事件(具体值决定与delayfunc, 这里为秒);
# 优先级(两个事件在同一时间到达的情况);
# 触发的函数;
# 函数参数;
s.enter(10, 1, print_time, ()) # 运行
s.run() if __name__ == '__main__':
print_some_times()

之间相差5秒,确定了多线程的执行顺序。

 import sched,time

 def print_time(msg="default"):
print("当前时间",time.time(),msg) def time_other():
print("优先度2",time.time()) print(time.time()) s=sched.scheduler(time.time,time.sleep) s.enter(10,1,print_time,())
s.enter(5,1,print_time,())
s.enter(5,2,time_other,())
s.run() print(time.time())

四、可执行程序的转换

第三步注意,一定要在同一个路径下

首先应该安装pyinstaller库

但是该库目前不支持python3.6,所以结果如下

最新文章

  1. 【原创】开源.NET排列组合组件KwCombinatorics使用(二)——排列生成
  2. Windows XP SP3下成功编译CUint2.1-3
  3. C++虚函数表
  4. ASP.NET技巧:教你制做Web实时进度条
  5. android设置图片自适应控件大小
  6. 防止ARP欺骗的方法!!!
  7. 回答了个问题,9x9 乘法表生成器
  8. request.getSession()
  9. 纯css3实现tab选项卡
  10. DotNetCore跨平台~聊聊中间件
  11. AMBER: CPPTRAJ Tutorial C0
  12. ServletContext、ServletRequest和HttpSession的生命周期
  13. NOIP2016解题报告
  14. [MapReduce_5] MapReduce 中的 Combiner 组件应用
  15. 代码:CSS仿制 苹果按钮图标
  16. 获取表单提交MVC错误信息
  17. 利器推荐-Snipaste截图工具
  18. windows环境vagrant修改静态资源文件,centos虚拟机中nginx的web环境下不生效
  19. Nginx 事件基本处理流程分析
  20. 数据库性能优化之SQL优化

热门文章

  1. PHPRAP v1.0.6 发布,修复因php7.1版本遗弃mcrypt扩展造成安装失败的BUG
  2. scroll-view组件bindscroll实例应用:自定义滚动条
  3. NLP自然语言处理入门-- 文本预处理Pre-processing
  4. Eureka停更了?试试Zookpper和Consul
  5. layui表格数据渲染SpringBoot+Thymeleaf返回的数据时报错(Caused by: org.attoparser.ParseException: Could not parse as expression: ")
  6. 关于adsl vps 拨号ip服务器
  7. ajax 瀑布流 demo
  8. C++ 理解类 和 类中的public、protected、private
  9. 03.文件I/O
  10. java常用日期类总结