اسلاید سوم جلسه هفتم کلاس پایتون برای هکرهای قانونی

181 views
151 views

Published on

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
181
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

اسلاید سوم جلسه هفتم کلاس پایتون برای هکرهای قانونی

  1. 1. Python for Ethical Hackers Mohammad reza Kamalifard
  2. 2. Python Language Essentials Module 2: System Programming Part 2 : Directory Navigation
  3. 3. Directory Details Methods for traversing directories Listing file and their information Creating and deleting directories and files Test to check if something is a file or directory
  4. 4. >>> import os >>> >>> os.getcwd() '/home/reza/code/PYSEC101/dir' >>> >>> >>>os.mkdir('class') $ ls Class jalase7 jalase7.py os.rmdir()
  5. 5. >>> os.listdir('.') ['class', 'jalase7', 'jalase7.py'] >>> >>> os.listdir('/') ['opt', 'initrd.img.old', 'lib', 'selinux', 'dev', 'home', 'initrd.img', 'lost+found', 'bin', 'usr', 'sys', 'lib64', 'windows', 'vmlinuz.old', 'proc', 'tmp', 'cdrom', 'run', 'sbin', 'mnt', 'root', 'boot', 'media', 'var', 'vmlinuz', 'etc', 'srv'] >>>
  6. 6. >>> for item in os.listdir('.'): ... if os.path.isfile(item): ... print item + ' is a file' ... elif os.path.isdir(item): ... print item + ' is a directory' ... else: ... print 'unknown' ... Class is a directory Jalase7 is a directory jalase7.py is a file >>>
  7. 7. This work is licensed under the Creative Commons Attribution-NoDerivs 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nd/3.0/ Copyright 2013 Mohammad reza Kamalifard. All rights reserved.

×