- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create hardlink of a file using Python?
The method os.link(src, dst) creates a hard link pointing to src named dst. This method is very useful to create a copy of existing file.
Example
For example, if you have a file called photo.jpg and want to create a hard link to it called my_photo.jpg, then you could simply use:
>>> import os >>> os.link('photo.jpg', 'my_photo.jpg')
Now if you list the files in that directory, you'll get the my_photo
Advertisements