function4.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. """
  2. Python常用模块
  3. - 运行时服务相关模块: copy / pickle / sys / ...
  4. - 数学相关模块: decimal / math / random / ...
  5. - 字符串处理模块: codecs / re / ...
  6. - 文件处理相关模块: shutil / gzip / ...
  7. - 操作系统服务相关模块: datetime / os / time / logging / io / ...
  8. - 进程和线程相关模块: multiprocessing / threading / queue
  9. - 网络应用相关模块: ftplib / http / smtplib / urllib / ...
  10. - Web编程相关模块: cgi / webbrowser
  11. - 数据处理和编码模块: base64 / csv / html.parser / json / xml / ...
  12. Version: 0.1
  13. Author: 骆昊
  14. Date: 2018-03-05
  15. """
  16. import time
  17. import shutil
  18. import os
  19. seconds = time.time()
  20. print(seconds)
  21. localtime = time.localtime(seconds)
  22. print(localtime)
  23. print(localtime.tm_year)
  24. print(localtime.tm_mon)
  25. print(localtime.tm_mday)
  26. asctime = time.asctime(localtime)
  27. print(asctime)
  28. strtime = time.strftime('%Y-%m-%d %H:%M:%S', localtime)
  29. print(strtime)
  30. mydate = time.strptime('2018-1-1', '%Y-%m-%d')
  31. print(mydate)
  32. shutil.copy('/Users/Hao/hello.py', '/Users/Hao/Desktop/first.py')
  33. os.system('ls -l')
  34. os.chdir('/Users/Hao')
  35. os.system('ls -l')
  36. os.mkdir('test')