

{"id":11112,"date":"2018-03-19T06:32:11","date_gmt":"2018-03-19T01:02:11","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=11112"},"modified":"2026-04-24T14:49:03","modified_gmt":"2026-04-24T09:19:03","slug":"python-os-module","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/python-os-module\/","title":{"rendered":"List of 63 Python os Module with Syntax &amp; Examples (Latest)"},"content":{"rendered":"<p>In this tutorial on Python os Module, we will get closer to the os module and its methods. Moreover, we will study syntax and examples of os Module in Python Programming Language.<\/p>\n<p>So, let&#8217;s start Python Module Tutorial<\/p>\n<div id=\"attachment_11552\" style=\"width: 1210px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Python-os-Module-01.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-11552\" class=\"wp-image-11552 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Python-os-Module-01.jpg\" alt=\"Python OS Module\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Python-os-Module-01.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Python-os-Module-01-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Python-os-Module-01-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Python-os-Module-01-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Python-os-Module-01-1024x536.jpg 1024w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><p id=\"caption-attachment-11552\" class=\"wp-caption-text\">List of 63 Python os Module with Syntax &amp; Examples (Latest)<\/p><\/div>\n<h3>What is the Python OS Module?<\/h3>\n<p>The OS module in Python lets us work with files and directories. We have been using it a lot to get to the Desktop in our examples. But it is much more.<\/p>\n<p><strong>Why should you use the OS Module in Python?<\/strong><\/p>\n<ul>\n<li><strong>Housekeeper:<\/strong> The OS Module can automatically move the messy files into a folder according to the date and time.<\/li>\n<li><strong>Find a way:<\/strong> The Python OS module tells the script which document folder you are currently running in.<\/li>\n<li><strong>Hidden safe:<\/strong> The code can be secretly written in your computer, which is called the environmental variable. When the script is run, the os module grabs the password.<\/li>\n<\/ul>\n<p>Let\u2019s discuss the important functions\/methods it offers. In case of any doubt, please ask us in the comments.<\/p>\n<p>Let\u2019s check the dir() on this module?<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; dir(os)<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">&gt;[&#8216;DirEntry&#8217;, &#8216;F_OK&#8217;, &#8216;MutableMapping&#8217;, &#8216;O_APPEND&#8217;, &#8216;O_BINARY&#8217;, &#8216;O_CREAT&#8217;, &#8216;O_EXCL&#8217;, &#8216;O_NOINHERIT&#8217;, &#8216;O_RANDOM&#8217;, &#8216;O_RDONLY&#8217;, &#8216;O_RDWR&#8217;, &#8216;O_SEQUENTIAL&#8217;, &#8216;O_SHORT_LIVED&#8217;, &#8216;O_TEMPORARY&#8217;, &#8216;O_TEXT&#8217;, &#8216;O_TRUNC&#8217;, &#8216;O_WRONLY&#8217;, &#8216;P_DETACH&#8217;, &#8216;P_NOWAIT&#8217;, &#8216;P_NOWAITO&#8217;, &#8216;P_OVERLAY&#8217;, &#8216;P_WAIT&#8217;, &#8216;PathLike&#8217;, &#8216;R_OK&#8217;, &#8216;SEEK_CUR&#8217;, &#8216;SEEK_END&#8217;, &#8216;SEEK_SET&#8217;, &#8216;TMP_MAX&#8217;, &#8216;W_OK&#8217;, &#8216;X_OK&#8217;, &#8216;_Environ&#8217;, &#8216;__all__&#8217;, &#8216;__builtins__&#8217;, &#8216;__cached__&#8217;, &#8216;__doc__&#8217;, &#8216;__file__&#8217;, &#8216;__loader__&#8217;, &#8216;__name__&#8217;, &#8216;__package__&#8217;, &#8216;__spec__&#8217;, &#8216;_execvpe&#8217;, &#8216;_exists&#8217;, &#8216;_exit&#8217;, &#8216;_fspath&#8217;, &#8216;_get_exports_list&#8217;, &#8216;_putenv&#8217;, &#8216;_unsetenv&#8217;, &#8216;_wrap_close&#8217;, &#8216;abc&#8217;, &#8216;abort&#8217;, &#8216;access&#8217;, &#8216;altsep&#8217;, &#8216;chdir&#8217;, &#8216;chmod&#8217;, &#8216;close&#8217;, &#8216;closerange&#8217;, &#8216;cpu_count&#8217;, &#8216;curdir&#8217;, &#8216;defpath&#8217;, &#8216;device_encoding&#8217;, &#8216;devnull&#8217;, &#8216;dup&#8217;, &#8216;dup2&#8217;, &#8216;environ&#8217;, &#8216;errno&#8217;, &#8216;error&#8217;, &#8216;execl&#8217;, &#8216;execle&#8217;, &#8216;execlp&#8217;, &#8216;execlpe&#8217;, &#8216;execv&#8217;, &#8216;execve&#8217;, &#8216;execvp&#8217;, &#8216;execvpe&#8217;, &#8216;extsep&#8217;, &#8216;fdopen&#8217;, &#8216;fsdecode&#8217;, &#8216;fsencode&#8217;, &#8216;fspath&#8217;, &#8216;fstat&#8217;, &#8216;fsync&#8217;, &#8216;ftruncate&#8217;, &#8216;get_exec_path&#8217;, &#8216;get_handle_inheritable&#8217;, &#8216;get_inheritable&#8217;, &#8216;get_terminal_size&#8217;, &#8216;getcwd&#8217;, &#8216;getcwdb&#8217;, &#8216;getenv&#8217;, &#8216;getlogin&#8217;, &#8216;getpid&#8217;, &#8216;getppid&#8217;, &#8216;isatty&#8217;, &#8216;kill&#8217;, &#8216;linesep&#8217;, &#8216;link&#8217;, &#8216;listdir&#8217;, &#8216;lseek&#8217;, &#8216;lstat&#8217;, &#8216;makedirs&#8217;, &#8216;mkdir&#8217;, &#8216;name&#8217;, &#8216;open&#8217;, &#8216;pardir&#8217;, &#8216;path&#8217;, &#8216;pathsep&#8217;, &#8216;pipe&#8217;, &#8216;popen&#8217;, &#8216;putenv&#8217;, &#8216;read&#8217;, &#8216;readlink&#8217;, &#8216;remove&#8217;, &#8216;removedirs&#8217;, &#8216;rename&#8217;, &#8216;renames&#8217;, &#8216;replace&#8217;, &#8216;rmdir&#8217;, &#8216;scandir&#8217;, &#8216;sep&#8217;, &#8216;set_handle_inheritable&#8217;, &#8216;set_inheritable&#8217;, &#8216;spawnl&#8217;, &#8216;spawnle&#8217;, &#8216;spawnv&#8217;, &#8216;spawnve&#8217;, &#8216;st&#8217;, &#8216;startfile&#8217;, &#8216;stat&#8217;, &#8216;stat_float_times&#8217;, &#8216;stat_result&#8217;, &#8216;statvfs_result&#8217;, &#8216;strerror&#8217;, &#8216;supports_bytes_environ&#8217;, &#8216;supports_dir_fd&#8217;, &#8216;supports_effective_ids&#8217;, &#8216;supports_fd&#8217;, &#8216;supports_follow_symlinks&#8217;, &#8216;symlink&#8217;, &#8216;sys&#8217;, &#8216;system&#8217;, &#8216;terminal_size&#8217;, &#8216;times&#8217;, &#8216;times_result&#8217;, &#8216;truncate&#8217;, &#8216;umask&#8217;, &#8216;uname_result&#8217;, &#8216;unlink&#8217;, &#8216;urandom&#8217;, &#8216;utime&#8217;, &#8216;waitpid&#8217;, &#8216;walk&#8217;, &#8216;write&#8217;]<\/div>\n<h3>1. access(path,mode) method in Python<\/h3>\n<p>This method uses the real uid\/gid to test for access to a path. If access is allowed, it returns True.<\/p>\n<p>Else, it returns False. The first argument is the path; the second is the mode.<\/p>\n<p>The mode can take one of four values:<\/p>\n<ol>\n<li>os.F_OK \u00a0&#8212; Found<\/li>\n<li>os.R_OK \u00a0&#8212; Readable<\/li>\n<li>os.W_OK \u00a0&#8212; Writable<\/li>\n<li>os.X_OK \u00a0&#8212; Executable<\/li>\n<\/ol>\n<p>Now, let\u2019s take an example.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; os.chdir('C:\\\\Users\\\\lifei\\\\Desktop')\r\n&gt;&gt;&gt; os.access('Today.txt',os.R_OK)<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">True<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; os.access('Today.txt',os.F_OK)<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">True<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; os.access('Today.txt',os.W_OK)<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">True<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; os.access('Today.txt',os.X_OK)<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">True<\/div>\n<h3>2. chdir(path) method in Python<\/h3>\n<p>This Python os module changes the current working directory to the path we specify.<\/p>\n<p>Does this need another example?<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; os.chdir('C:\\\\Users\\\\lifei\\\\Desktop')<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">It returns None.<\/div>\n<h3>3. chflags(path,flags) method in Python<\/h3>\n<p>chflags() sets path flags to the numeric flags. These flags may take a combination(bitwise OR) of the following values:<\/p>\n<ul>\n<li>os.UF_NODUMP \u2013 Don\u2019t dump the file<\/li>\n<li>os.UF_IMMUTABLE \u2212 You may not change the file<\/li>\n<li>os.UF_APPEND \u2212 You may only append to the file<\/li>\n<li>os.UF_NOUNLINK \u2013 You may not rename or delete the file<\/li>\n<li>os.UF_OPAQUE \u2212 The directory is opaque when we view it through a union stack<\/li>\n<li>os.SF_ARCHIVED \u2013 You may archive the file<\/li>\n<li>os.SF_IMMUTABLE \u2013 You may not change the file<\/li>\n<li>os.SF_APPEND \u2013 You may only append to the file<\/li>\n<li>os.SF_NOUNLINK \u2013 You may not rename or delete the file<\/li>\n<li>os.SF_SNAPSHOT \u2212 It is a snapshot file<\/li>\n<\/ul>\n<p>Most flags are such that only the super-user can change them. Also, some flags don\u2019t work on all systems.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; os.chflags('Today.txt',os.SF_NOUNLINK)<\/pre>\n<h3>4. chmod(path,mode) method in Python<\/h3>\n<p>This Python os Module alters the mode of the path to the passed numeric mode.<\/p>\n<p>The mode may be on of the following values(or a bitwise OR combination of them):<\/p>\n<ul>\n<li>stat.S_ISUID \u2212 Set user ID on execution<\/li>\n<li>stat.S_ISGID \u2212 Set group ID on execution<\/li>\n<li>stat.S_ENFMT \u2013 Enforced record locking<\/li>\n<li>stat.S_ISVTX \u2013 After execution, save text image<\/li>\n<li>stat.S_IREAD \u2212 Read by owner<\/li>\n<li>stat.S_IWRITE \u2212 Write by owner<\/li>\n<li>stat.S_IEXEC \u2212 Execute by owner<\/li>\n<li>stat.S_IRWXU \u2212 Read, write, and execute by owner<\/li>\n<li>stat.S_IRUSR \u2212 Read by owner<\/li>\n<li>stat.S_IWUSR \u2212 Write by owner<\/li>\n<li>stat.S_IXUSR \u2212 Execute by owner<\/li>\n<li>stat.S_IRWXG \u2212 Read, write, and execute by group<\/li>\n<li>stat.S_IRGRP \u2212 Read by group<\/li>\n<li>stat.S_IWGRP \u2212 Write by group<\/li>\n<li>stat.S_IXGRP \u2212 Execute by group<\/li>\n<li>stat.S_IRWXO \u2212 Read, write, and execute by others<\/li>\n<li>stat.S_IROTH \u2212 Read by others<\/li>\n<li>stat.S_IWOTH \u2212 Write by others<\/li>\n<li>stat.S_IXOTH \u2212 Execute by others<\/li>\n<\/ul>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; import stat\r\n&gt;&gt;&gt; os.chmod('Today.txt',stat.S_ISVTX)<\/pre>\n<p>This method does not return any value.<\/p>\n<h3>5. chroot(path) method in\u00a0<span style=\"font-size: 16px\">the<\/span><span style=\"font-size: 16px\">\u00a0Python <\/span><\/h3>\n<p><span style=\"font-size: 16px\">os.chroot(path) Module alters the current process\u2019s root directory to the given path.<\/span><\/p>\n<p>To use this, we need super-user privileges.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; os.chroot(\"\/Photos\")<\/pre>\n<p>This method returns no value.<\/p>\n<h3>6. close(fd) method in\u00a0the\u00a0Python<\/h3>\n<p>This Python os module closes the associated file with descriptor fd.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; fd=os.open('Today.txt',os.O_RDWR)\r\n&gt;&gt;&gt; os.close(fd)<\/pre>\n<p>It does not return any value.<\/p>\n<h3>7. closerange(fd_low,fd_high) method in\u00a0the\u00a0Python<\/h3>\n<p>closerange() closes all file descriptors from fd_low to fd_high. Here, fd_low is inclusive, and fd_high is exclusive.<\/p>\n<p>Here, fd_low is the lowest file descriptor to be closed, while fd_high is the highest. This method ignores errors.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; fd = os.open( \"Today.txt\", os.O_RDWR)\r\n&gt;&gt;&gt; os.write(fd, \"Testing\")\r\n&gt;&gt;&gt; os.closerange( fd, fd)<\/pre>\n<p>This method does not return any value.<\/p>\n<h3>8. dup(fd) method in\u00a0the\u00a0Python<\/h3>\n<p>Python os Module dup(fd) returns a duplicate of the file descriptor fd.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; fd = os.open( \"Today.txt\", os.O_RDWR)\r\n&gt;&gt;&gt; d_fd = os.dup( fd )\r\n&gt;&gt;&gt; os.write(d_fd, \"Testing\")\r\n&gt;&gt;&gt; os.closerange( fd, d_fd)<\/pre>\n<p>This method returns a duplicate of the file descriptor.<\/p>\n<h3>9. dup2(fd,fd2) method in\u00a0the\u00a0Python<\/h3>\n<p>dup2() duplicates the descriptor fd to fd2. And if necessary, it closes fd2 first.<\/p>\n<p>The interpreter assigns the new file description only when it is available.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; fd = os.open( \"Today.txt\", os.O_RDWR)\r\n&gt;&gt;&gt; os.write(fd, \"Testing\")\r\n&gt;&gt;&gt; fd2 = 1000\r\n&gt;&gt;&gt; os.dup2(fd, fd2)\r\n&gt;&gt;&gt; os.lseek(fd2, 0, 0)\r\n&gt;&gt;&gt; str = os.read(fd2, 100)\r\n&gt;&gt;&gt; print(f\"Read String is {str}\")\r\n&gt;&gt;&gt; os.close( fd )<\/pre>\n<p>This method returns a duplicate of the file descriptor.<\/p>\n<h3>10. fchdir(fd) method in\u00a0the\u00a0Python<\/h3>\n<p>fchdir() alters the current working directory to the directory that the file descriptor fd represents.<\/p>\n<p>For this, it is mandatory that the descriptor must refer to an opened directory, and not to an open file.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; os.chdir(\"\/var\/www\/html\" )\r\n&gt;&gt;&gt; print \"Current working dir : %s\" % os.getcwd()\r\n&gt;&gt;&gt; fd = os.open( \"\/tmp\", os.O_RDONLY )\r\n&gt;&gt;&gt; os.fchdir(fd)\r\n&gt;&gt;&gt; print \"Current working dir : %s\" % os.getcwd()\r\n&gt;&gt;&gt; os.close( fd )<\/pre>\n<p>This method doesn\u2019t return any value.<\/p>\n<h3>11. fchmod(fd,mode) method in\u00a0the\u00a0Python<\/h3>\n<p>This Python os Module alters the file mode of the file, specified by fd, to the numeric mode.<\/p>\n<p>The mode may be one of the following (or an ORed combination of):<\/p>\n<ul>\n<li>stat.S_ISUID \u2212 Set user ID on execution<\/li>\n<li>stat.S_ISGID \u2212 Set group ID on execution<\/li>\n<li>stat.S_ENFMT \u2212 Record locking enforced<\/li>\n<li>stat.S_ISVTX \u2212 Save text image after execution<\/li>\n<li>stat.S_IREAD \u2212 Read by owner<\/li>\n<li>stat.S_IWRITE \u2212 Write by owner<\/li>\n<li>stat.S_IEXEC \u2212 Execute by owner<\/li>\n<li>stat.S_IRWXU \u2212 Read, write, and execute by owner<\/li>\n<li>stat.S_IRUSR \u2212 Read by owner<\/li>\n<li>stat.S_IWUSR \u2212 Write by owner<\/li>\n<li>stat.S_IXUSR \u2212 Execute by owner<\/li>\n<li>stat.S_IRWXG \u2212 Read, write, and execute by group<\/li>\n<li>stat.S_IRGRP \u2212 Read by group<\/li>\n<li>stat.S_IWGRP \u2212 Write by group<\/li>\n<li>stat.S_IXGRP \u2212 Execute by group<\/li>\n<li>stat.S_IRWXO \u2212 Read, write, and execute by others<\/li>\n<li>stat.S_IROTH \u2212 Read by others<\/li>\n<li>stat.S_IWOTH \u2212 Write by others<\/li>\n<li>stat.S_IXOTH \u2212 Execute by others<\/li>\n<\/ul>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; fd = os.open( \"\/tmp\", os.O_RDONLY )\r\n&gt;&gt;&gt; os.fchmod( fd, stat.S_IXGRP)\r\n&gt;&gt;&gt; os.fchmod(fd, stat.S_IWOTH)\r\n&gt;&gt;&gt; print \"Changed mode successfully!!\"\r\n&gt;&gt;&gt; os.close( fd )<\/pre>\n<p>This method doesn\u2019t return any value.<\/p>\n<h3>12. fchown(fd,uid,gid) method in\u00a0the\u00a0Python<\/h3>\n<p>fchown() alters the owner and the group id of the file specified by fd to the numeric uid and gid.<\/p>\n<p>Setting an id to -1 leaves it unchanged.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; fd = os.open( \"\/tmp\", os.O_RDONLY )\r\n&gt;&gt;&gt; os.fchown( fd, 100, -1)\r\n&gt;&gt;&gt; os.fchown( fd, -1, 50)\r\n&gt;&gt;&gt; print \"Changed ownership successfully!!\"\r\n&gt;&gt;&gt; os.close( fd )<\/pre>\n<p>This method doesn\u2019t return any value.<\/p>\n<h3>13. fdatasync(fd) method in\u00a0the\u00a0Python<\/h3>\n<p>fdatasync() forces writing the file with filedescriptor fd to disk. This, however, doesn\u2019t force update on metadata.<\/p>\n<p>You can do this to flush your buffer.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; fd = os.open( \"Today.txt\", os.O_RDWR)\r\n&gt;&gt;&gt; os.write(fd, \"Testing\")\r\n&gt;&gt;&gt; os.fdatasync(fd)\r\n&gt;&gt;&gt; os.lseek(fd, 0, 0)\r\n&gt;&gt;&gt; str = os.read(fd, 100)\r\n&gt;&gt;&gt; print(f\"Read String is {str}\")\r\n&gt;&gt;&gt; os.close( fd )<\/pre>\n<p>This method doesn\u2019t return any value.<\/p>\n<h3>14. fdopen(fd[, mode[, bufsize]]) method in\u00a0the\u00a0Python<\/h3>\n<p>fdopen(), Python os Module returns an open file object. This object is connected to the descriptor fd.<\/p>\n<p>Once you do this, you can perform all defined functions on the file object.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; fd = os.open( \"Today.txt\", os.O_RDWR)\r\n&gt;&gt;&gt; fo = os.fdopen(fd, \"w+\")\r\n&gt;&gt;&gt; print (f\"Current I\/O pointer position {fo.tell()}\")\r\n&gt;&gt;&gt; fo.write( \"Python is a great language.\\nYeah its great!!\\n\");\r\n&gt;&gt;&gt; os.lseek(fd, 0, 0)\r\n&gt;&gt;&gt; str = os.read(fd, 100)\r\n&gt;&gt;&gt; print (f\"Read String is {str}\")\r\n&gt;&gt;&gt; print (f\"Current I\/O pointer position {fo.tell()}\")\r\n&gt;&gt;&gt; fo.close()<\/pre>\n<p>fdopen() returns an open file object that is connected to the file descriptor.<\/p>\n<h3>15. fpathconf(fd, name) method in\u00a0the\u00a0Python<\/h3>\n<p>fpathconf() returns system configuration information that is relevant to an open file.<\/p>\n<p>This is quite similar to the Unix system call fpathconf(). It also accepts similar arguments.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; fd = os.open( \"Today.txt\", os.O_RDWR)\r\n&gt;&gt;&gt; print (f\"{os.pathconf_names}\")\r\n&gt;&gt;&gt; no = os.fpathconf(fd, 'PC_LINK_MAX')\r\n&gt;&gt;&gt; print (f\"Maximum number of links to the file: {no}\")\r\n&gt;&gt;&gt; no = os.fpathconf(fd, 'PC_NAME_MAX')\r\n&gt;&gt;&gt; print (f\"Maximum length of a filename :{no}\")\r\n&gt;&gt;&gt; os.close( fd)<\/pre>\n<p>fpathconf() returns system configuration that is relevant to an open file.<\/p>\n<h3>16. fstat(fd) method in Python<\/h3>\n<p>Python os Module fstat() returns information about the file pertaining to the fd.<\/p>\n<p>Let\u2019s take a look at the structure fstat() returns:<\/p>\n<ul>\n<li>st_dev \u2212 ID of device containing file<\/li>\n<li>st_ino \u2212 inode number<\/li>\n<li>st_mode \u2013 protection<\/li>\n<li>st_nlink \u2212 number of hard links<\/li>\n<li>st_uid \u2212 user ID of owner<\/li>\n<li>st_gid \u2212 group ID of owner<\/li>\n<li>st_rdev \u2212 device ID (if special file)<\/li>\n<li>st_size \u2212 total size, in bytes<\/li>\n<li>st_blksize \u2212 blocksize for filesystem I\/O<\/li>\n<li>st_blocks \u2212 number of blocks allocated<\/li>\n<li>st_atime \u2212 time of last access<\/li>\n<li>st_mtime \u2212 time of last modification<\/li>\n<li>st_ctime \u2212 time of last status change<\/li>\n<\/ul>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; fd = os.open( \"Today.txt\", os.O_RDWR)\r\n&gt;&gt;&gt; info = os.fstat(fd)\r\n&gt;&gt;&gt; print (f\"File Info: {info}\")\r\n&gt;&gt;&gt; print (f\"UID of the file: {info.st_uid}\")\r\n&gt;&gt;&gt; print (f\"GID of the file: {info.st_gid}\")\r\n&gt;&gt;&gt; os.close( fd)<\/pre>\n<p>fstat() returns information about the file linked with the fd.<\/p>\n<h3>17. fstatvfs(fd) method in Python<\/h3>\n<p>This Python os module returns information pertaining to the file system containing the file linked with file descriptor fd.<\/p>\n<p>This is the structure it returns:<\/p>\n<ul>\n<li>f_bsize \u2212 file system block size<\/li>\n<li>f_frsize \u2212 fragment size<\/li>\n<li>f_blocks \u2212 size of fs in f_frsize units<\/li>\n<li>f_bfree \u2212 free blocks<\/li>\n<li>f_bavail \u2212 free blocks for non-root<\/li>\n<li>f_files \u2013 inodes<\/li>\n<li>f_ffree \u2212 free inodes<\/li>\n<li>f_favail \u2212 free inodes for non-root<\/li>\n<li>f_fsid \u2212 file system ID<\/li>\n<li>f_flag \u2212 mount flags<\/li>\n<li>f_namemax \u2212 maximum filename length<\/li>\n<\/ul>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; fd = os.open( \"Today.txt\", os.O_RDWR)\r\n&gt;&gt;&gt; info = os.fstatvfs(fd)\r\n&gt;&gt;&gt; print(f\"File Info: {info}\")\r\n&gt;&gt;&gt; print(f\"Maximum filename length: {info.f_namemax}\")\r\n&gt;&gt;&gt; print (f\"Free blocks: {info.f_bfree}\")\r\n&gt;&gt;&gt; os.close( fd)<\/pre>\n<p>fstatvfs() returns information about the file system containing the file linked.<\/p>\n<h3>18. fsync(fd) method in Python<\/h3>\n<p>This Python os Module forces write on the file liknked to the descriptor fd to disk.<\/p>\n<p>Beginning with a Python file object f, first execute f.flush(), then perform os.fsync(f.fileno()).<\/p>\n<p>Do this to ensure all internal buffers linked to f are written to the disk.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; fd = os.open( \"Today.txt\", os.O_RDWR)\r\n&gt;&gt;&gt; os.write(fd, \"Testing\")\r\n&gt;&gt;&gt; os.fsync(fd)\r\n&gt;&gt;&gt; os.lseek(fd, 0, 0)\r\n&gt;&gt;&gt; str = os.read(fd, 100)\r\n&gt;&gt;&gt; print(\"Read String is: {str} \")\r\n&gt;&gt;&gt; os.close( fd )<\/pre>\n<p>fsync() doesn\u2019t return any value.<\/p>\n<h3>19. ftruncate(fd,length) method in Python<\/h3>\n<p>ftruncate() truncates the file linked to the descriptor fd, so it holds at most length bytes in size.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; fd = os.open( \"Today.txt\", os.O_RDWR)\r\n&gt;&gt;&gt; os.write(fd, \"Testing\")\r\n&gt;&gt;&gt; os.ftruncate(fd, 10)\r\n&gt;&gt;&gt; os.lseek(fd, 0, 0)\r\n&gt;&gt;&gt; str = os.read(fd, 100)\r\n&gt;&gt;&gt; print(\"Read String is: {str}\u201d)\r\n&gt;&gt;&gt; os.close( fd )<\/pre>\n<p>ftruncate() doesn\u2019t return any value.<\/p>\n<h3>20. getcwd() method in Python<\/h3>\n<p>getcwd() Python os Module returns the current working directory of a process.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; os.getcwd()<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">&#8216;C:\\\\Users\\\\lifei\\\\Desktop&#8217;<\/div>\n<h3>21. getcwdu() method in Python<\/h3>\n<p>getcwdu() returns a Unicode object that represents the current working directory.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; os.chdir(\"\/var\/www\/html\" )\r\n&gt;&gt;&gt; print(f\"Current working dir: {os.getcwdu()}\")\r\n&gt;&gt;&gt; fd = os.open( \"\/tmp\", os.O_RDONLY )\r\n&gt;&gt;&gt; os.fchdir(fd)\r\n&gt;&gt;&gt; print(f\"Current working dir: {os.getcwdu()}\u201d)\r\n&gt;&gt;&gt; os.close( fd )<\/pre>\n<h3>22. isatty(fd) method in Python<\/h3>\n<p>isatty()returns True if the descriptor fd is open, and is connected to a tty(-like) device. Otherwise, it returns False.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; fd = os.open( \"Today.txt\", os.O_RDWR)\r\n&gt;&gt;&gt; os.write(fd, \"Testing\")\r\n&gt;&gt;&gt; ret = os.isatty(fd)\r\n&gt;&gt;&gt; print(f\"Returned value is: {ret}\")\r\n&gt;&gt;&gt; os.close( fd )<\/pre>\n<h3>23. lchflags(path,flags) method in Python<\/h3>\n<p>This Python os Module sets path flags to the numeric flags. Unlike chflags(), ut doesn\u2019t follow symbolic links.<\/p>\n<p>The flags may be one of the following values, or a bitwise OR combination of:<\/p>\n<ul>\n<li>UF_NODUMP \u2212 Do not dump the file<\/li>\n<li>UF_IMMUTABLE \u2212 The file may not be changed<\/li>\n<li>UF_APPEND \u2212 The file may only be appended to<\/li>\n<li>UF_NOUNLINK \u2212 The file may not be renamed or deleted<\/li>\n<li>UF_OPAQUE \u2212 The directory is opaque when viewed through a union stack<\/li>\n<li>SF_ARCHIVED \u2212 The file may be archived<\/li>\n<li>SF_IMMUTABLE \u2212 The file may not be changed<\/li>\n<li>SF_APPEND \u2212 The file may only be appended to<\/li>\n<li>SF_NOUNLINK \u2212 The file may not be renamed or deleted<\/li>\n<li>SF_SNAPSHOT \u2212 The file is a snapshot file.<\/li>\n<\/ul>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; path = \"\/var\/www\/html\/Today.txt\"\r\n&gt;&gt;&gt; fd = os.open( path, os.O_RDWR)\r\n&gt;&gt;&gt; os.close( fd )\r\n&gt;&gt;&gt; ret = os.lchflags(path, os.UF_IMMUTABLE )<\/pre>\n<p>lchflags() doesn\u2019t return a value.<\/p>\n<h3>24. lchmod(path,mode) method in Python<\/h3>\n<p>lchmod() Python os Module ters the path mode to the numeric mode. If the path is a symlink, it affects the symlink, not the target.<\/p>\n<p>The mode may be one of the following values, or a bitwise OR combination of:<\/p>\n<ul>\n<li>stat.S_ISUID \u2212 Set user ID on execution<\/li>\n<li>stat.S_ISGID \u2212 Set group ID on execution<\/li>\n<li>stat.S_ENFMT \u2212 Record locking enforced<\/li>\n<li>stat.S_ISVTX \u2212 Save text image after execution<\/li>\n<li>stat.S_IREAD \u2212 Read by owner<\/li>\n<li>stat.S_IWRITE \u2212 Write by owner<\/li>\n<li>stat.S_IEXEC \u2212 Execute by owner<\/li>\n<li>stat.S_IRWXU \u2212 Read, write, and execute by owner<\/li>\n<li>stat.S_IRUSR \u2212 Read by owner<\/li>\n<li>stat.S_IWUSR \u2212 Write by owner<\/li>\n<li>stat.S_IXUSR \u2212 Execute by owner<\/li>\n<li>stat.S_IRWXG \u2212 Read, write, and execute by group<\/li>\n<li>stat.S_IRGRP \u2212 Read by group<\/li>\n<li>stat.S_IWGRP \u2212 Write by group<\/li>\n<li>stat.S_IXGRP \u2212 Execute by group<\/li>\n<li>stat.S_IRWXO \u2212 Read, write, and execute by others<\/li>\n<li>stat.S_IROTH \u2212 Read by others<\/li>\n<li>stat.S_IWOTH \u2212 Write by others<\/li>\n<li>stat.S_IXOTH \u2212 Execute by others<\/li>\n<\/ul>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; path = \"\/var\/www\/html\/Today.txt\"\r\n&gt;&gt;&gt; fd = os.open( path, os.O_RDWR )\r\n&gt;&gt;&gt; os.close( fd )\r\n&gt;&gt;&gt; os.lchmod( path, stat.S_IXGRP)\r\n&gt;&gt;&gt; os.lchmod(\"\/tmp\/Today.txt\", stat.S_IWOTH)<\/pre>\n<p>lchmod() doesn\u2019t return any value.<\/p>\n<h3>25. lchown(path,uid,gid) method in Python<\/h3>\n<p>Python os Module lchown() alters the owner and group ID of the path to the numeric uid and gid.<\/p>\n<p>It doesn\u2019t follow symbolic links. Setting an id to -1 leaves it unchanged.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; path = \"\/var\/www\/html\/Today.txt\"\r\n&gt;&gt;&gt; fd = os.open( path, os.O_RDWR)\r\n&gt;&gt;&gt; os.close( fd )\r\n&gt;&gt;&gt; os.lchown( path, 500, -1)\r\n&gt;&gt;&gt; os.lchown( path, -1, 500)<\/pre>\n<p>lchown() doesn\u2019t return any value.<\/p>\n<h3>26. link(src,dst) method in Python<\/h3>\n<p>link() will create a hard link that points to an src named dst.<\/p>\n<p>You can do this when you want to create a copy of an existing file.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; path = \"\/var\/www\/html\/Today.txt\"\r\n&gt;&gt;&gt; fd = os.open( path, os.O_RDWR )\r\n&gt;&gt;&gt; os.close( fd )\r\n&gt;&gt;&gt; dst = \"\/tmp\/Today.txt\"\r\n&gt;&gt;&gt; os.link( path, dst)<\/pre>\n<p>lilnk() doesn\u2019t return any value.<\/p>\n<h3>27. The listdir(path) method in Python<\/h3>\n<p>listdir() will return a list holding the names of the entries in the directory at the path.<\/p>\n<p>This list is in an arbitrary order, and it excludes special entries &#8216;.&#8217; and &#8216;..&#8217;, even if they exist in the directory.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; path = \"\/var\/www\/html\/\"\r\n&gt;&gt;&gt; dirs = os.listdir( path )\r\n&gt;&gt;&gt; for file in dirs:\r\nprint(file)<\/pre>\n<h3>28. lseek(fd,pos,how) method in Python<\/h3>\n<p>lseek() will set the current position of the descriptor fd to the specified position pos. \u2018how\u2019 modifies it.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; fd = os.open( \"Today.txt\", os.O_RDWR)\r\n&gt;&gt;&gt; os.write(fd, \"This is test\")\r\n&gt;&gt;&gt; os.fsync(fd)\r\n&gt;&gt;&gt; os.lseek(fd, 0, 0)\r\n&gt;&gt;&gt; str = os.read(fd, 100)\r\n&gt;&gt;&gt; print(f\"Read String is: {str}\")\r\n&gt;&gt;&gt; os.close( fd )<\/pre>\n<p>lseek() doesn\u2019t return any value.<\/p>\n<h3>29. lstat(path) method in Python<\/h3>\n<p>Like fstat(), lstat() returns information about a file, but does not follow symbolic links.<\/p>\n<p>lstat is an alias for fstat() on those platforms that do not support symbolic links, for instance, Windows.<\/p>\n<p>It returns the following structure:<\/p>\n<ul>\n<li>st_dev \u2212 ID of device containing file<\/li>\n<li>st_ino \u2212 inode number<\/li>\n<li>st_mode \u2013 protection<\/li>\n<li>st_nlink \u2212 number of hard links<\/li>\n<li>st_uid \u2212 user ID of owner<\/li>\n<li>st_gid \u2212 group ID of owner<\/li>\n<li>st_rdev \u2212 device ID (if special file)<\/li>\n<li>st_size \u2212 total size, in bytes<\/li>\n<li>st_blksize \u2212 blocksize for filesystem I\/O<\/li>\n<li>st_blocks \u2212 number of blocks allocated<\/li>\n<li>st_atime \u2212 time of last access<\/li>\n<li>st_mtime \u2212 time of last modification<\/li>\n<li>st_ctime \u2212 time of last status change<\/li>\n<\/ul>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; path = \"\/var\/www\/html\/Today.txt\"\r\n&gt;&gt;&gt; fd = os.open( path, os.O_RDWR)\r\n&gt;&gt;&gt; os.close( fd )\r\n&gt;&gt;&gt; info = os.lstat(path)\r\n&gt;&gt;&gt; print(f\"File Info: {info}\")\r\n&gt;&gt;&gt; print(f\"UID of the file: {info.st_uid}\")\r\n&gt;&gt;&gt; print(f\"GID of the file: {info.st_gid}\")<\/pre>\n<h3>30. major(device) method in Python<\/h3>\n<p>major() takes a raw device number, and extracts the device major number (usually the st_dev or st_rdev field from stat).<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; path = \"\/var\/www\/html\/Today.txt\"\r\n&gt;&gt;&gt; info = os.lstat(path)\r\n&gt;&gt;&gt; major_dnum = os.major(info.st_dev)\r\n&gt;&gt;&gt; minor_dnum = os.minor(info.st_dev)\r\n&gt;&gt;&gt; print(f\"Major Device Number: {major_dnum}\")\r\n&gt;&gt;&gt; print(f\"Minor Device Number: {minor_dnum}\")<\/pre>\n<p>major() returns the device major number.<\/p>\n<h3>31. makedev(major,minor) method in Python<\/h3>\n<p>This Python os Module takes the minor and major device numbers and creates a raw device number.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; path = \"\/var\/www\/html\/Today.txt\"\r\n&gt;&gt;&gt; info = os.lstat(path)\r\n&gt;&gt;&gt; major_dnum = os.major(info.st_dev)\r\n&gt;&gt;&gt; minor_dnum = os.minor(info.st_dev)\r\n&gt;&gt;&gt; print(f\"Major Device Number: {major_dnum}\")\r\n&gt;&gt;&gt; print(f\"Minor Device Number: {minor_dnum}\")\r\n&gt;&gt;&gt; dev_num = os.makedev(major_dnum, minor_dnum)\r\n&gt;&gt;&gt; print(f\"Device Number: {dev_num}\")<\/pre>\n<p>makedev() returns the device number.<\/p>\n<h3>32. makedirs(path[, mode]) method in Python<\/h3>\n<p>makedirs() creates a directory recursively. This way, it is like mkdir().<\/p>\n<p>However, it mandates that all intermediate-level directories contain the leaf directory.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; path = \"\/tmp\/home\/monthly\/daily\"\r\n&gt;&gt;&gt; os.makedirs( path, 0755 )<\/pre>\n<h3>33. minor(device) method in Python<\/h3>\n<p>Python os Module minor() will take a raw device number, and extract the device\u2019s minor (usually the st_dev or st_rdev field from stat).<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; path = \"\/var\/www\/html\/Today.txt\"\r\n&gt;&gt;&gt; info = os.lstat(path)\r\n&gt;&gt;&gt; major_dnum = os.major(info.st_dev)\r\n&gt;&gt;&gt; minor_dnum = os.minor(info.st_dev)\r\n&gt;&gt;&gt; print(f\"Major Device Number: {major_dnum}\")\r\n&gt;&gt;&gt; print(f\"Minor Device Number: {minor_dnum}\")<\/pre>\n<p>minor() returns the device\u2019s minor number.<\/p>\n<h3>34. mkdir(path[, mode]) method in Python<\/h3>\n<p>mkdir() Python os Module creates a directory \u2018path\u2019 with the numeric mode \u2018mode\u2019. Some systems ignore mode.<\/p>\n<p>But where used, it masks out the current umask value first.<br \/>\nDefault mode=0777 (octal).<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; path = \"\/tmp\/home\/monthly\/daily\/hourly\"\r\n&gt;&gt;&gt; os.mkdir( path, 0755 )<\/pre>\n<p>mkdir() doesn\u2019t return any value.<\/p>\n<h3>35. mkfifo(path[, mode]) method in Python<\/h3>\n<p>mkfifo() creates a FIFO named \u2018path\u2019 with the specified numeric mode. It masks out the current umask value first.<br \/>\nDefault mode=0666 (octal).<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; path = \"\/tmp\/hourly\"\r\n&gt;&gt;&gt; os.mkfifo( path, 0644 )<\/pre>\n<p>mkfifo() doesn\u2019t return any value.<\/p>\n<h3>36. mknod(filename[, mode=0600, device]) method in Python<\/h3>\n<p>This Python os Module will create a filesystem node named \u2018filename\u2019. This can be a file, a device-special file, or a named pipe.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; filename = '\/tmp\/tmpfile'\r\n&gt;&gt;&gt; mode = 0600|stat.S_IRUSR\r\n&gt;&gt;&gt; os.mknod(filename, mode)<\/pre>\n<p>mknod() doesn\u2019t return any value.<\/p>\n<h3>37. open(file, flags[, mode]) method in Python<\/h3>\n<p>open() will open the file \u2018file\u2019, and will set flags based on the specified flags.<\/p>\n<p>It possibly sets its mode according to the specified mode. It also masks out the current umask value first.<\/p>\n<p>Default mode=0777 (octal).<\/p>\n<p>The flags may take one of these values, or a bitwise-OR combination of these:<\/p>\n<ul>\n<li>os.O_RDONLY \u2212 open for reading only<\/li>\n<li>os.O_WRONLY \u2212 open for writing only<\/li>\n<li>os.O_RDWR \u2212 open for reading and writing<\/li>\n<li>os.O_NONBLOCK \u2212 do not block on open<\/li>\n<li>os.O_APPEND \u2212 append on each write<\/li>\n<li>os.O_CREAT \u2212 create file if it does not exist<\/li>\n<li>os.O_TRUNC \u2212 truncate size to 0<\/li>\n<li>os.O_EXCL \u2212 error if create and file exists<\/li>\n<li>os.O_SHLOCK \u2212 atomically obtain a shared lock<\/li>\n<li>os.O_EXLOCK \u2212 atomically obtain an exclusive lock<\/li>\n<li>os.O_DIRECT \u2212 eliminate or reduce cache effects<\/li>\n<li>os.O_FSYNC \u2212 synchronous writes<\/li>\n<li>os.O_NOFOLLOW \u2212 do not follow symlinks<\/li>\n<\/ul>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; fd = os.open( \"Today.txt\", os.O_RDWR)\r\n&gt;&gt;&gt; os.write(fd, \"This is test\")\r\n&gt;&gt;&gt; os.close( fd )<\/pre>\n<p>open() returns the descriptor for the file we opened.<\/p>\n<h3>38. openpty() method in Python<\/h3>\n<p>Python os Module openpty() opens a pseudo-terminal pair.<\/p>\n<p>Then, it returns a pair of descriptors- master &amp; slave- for the pty &amp; the tty, respectively.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; m,s = os.openpty()\r\n&gt;&gt;&gt; print(m)\r\n&gt;&gt;&gt; print(s)\r\n&gt;&gt;&gt; s = os.ttyname(s)\r\n&gt;&gt;&gt; print(m)\r\n&gt;&gt;&gt; print(s)<\/pre>\n<h3>39. pathconf(path,name) method in Python<\/h3>\n<p>Python os Module pathconf() returns system configuration information pertaining to a named file.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; print(f\"{os.pathconf_names}\" )\r\n&gt;&gt;&gt; no = os.pathconf('a2.py', 'PC_NAME_MAX')\r\n&gt;&gt;&gt; print(f\"Maximum length of a filename: {no}\")\r\n&gt;&gt;&gt; no = os.pathconf('a2.py', 'PC_FILESIZEBITS')\r\n&gt;&gt;&gt; print(f\"file size in bits: {no}\")<\/pre>\n<h3>40. pipe() method in Python<\/h3>\n<p>pipe() creates a pipe. Then, it returns a pair of descriptors- r &amp; w- for reading and writing.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; os.pipe()<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">(3, 4)<\/div>\n<h3>41. popen(command[, mode[, bufsize]]) method in Python<\/h3>\n<p>This Python os Module popen() will open a pipe to, or from, the command specified. It returns an open file object that is connected to the pipe.<\/p>\n<p>We can read or write to this object depending on whether the mode is &#8216;r&#8217; (default) or &#8216;w&#8217;. The bufsize argument means the same as in the open() function.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; a = 'mkdir nwdir'\r\n&gt;&gt;&gt; b = os.popen(a,'r',1)<\/pre>\n<h3>42. read(fd,n) method in Python<\/h3>\n<p>read() Python os Module will let us read at most n bytes from the descriptor fd. It returns a string holding the bytes we just read.<\/p>\n<p>And if it reaches the end of the file, it returns an empty string.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; fd = os.open(\"f1.txt\",os.O_RDWR)\r\n&gt;&gt;&gt; ret = os.read(fd,12)\r\n&gt;&gt;&gt; print(ret)\r\n&gt;&gt;&gt; os.close(fd)<\/pre>\n<h3>43. readlink(path) method in Python<\/h3>\n<p>Python os Module readlink() will return a string denoting the path to which the symbolic link points. It may return a relative or an absolute pathname.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; src = '\/usr\/bin\/python'\r\n&gt;&gt;&gt; dst = '\/tmp\/python'\r\n&gt;&gt;&gt; os.symlink(src, dst)\r\n&gt;&gt;&gt; path = os.readlink( dst )\r\n&gt;&gt;&gt; print(path)<\/pre>\n<h3>44. remove(path) method in Python<\/h3>\n<p>remove() removes the specified file path. If that path is a directory, it raises an OSError.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; print(f\"The dir is: {os.listdir(os.getcwd())}\")\r\n&gt;&gt;&gt; os.remove(\"aa.txt\")\r\n&gt;&gt;&gt; print(f\"The dir after removal of path: {os.listdir(os.getcwd())}\")<\/pre>\n<p>remove() doesn\u2019t return any value.<\/p>\n<h3>45. removedirs(path) method in Python<\/h3>\n<p>This Python os Module will remove directories recursively.<\/p>\n<p>And if we successfully remove the leaf directory, it attempts to successively remove every parent directory displayed in that path.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; print(f\"The dir is: {os.listdir(os.getcwd())}\")\r\n&gt;&gt;&gt; os.removedirs(\"\/tutorialsdir\")\r\n&gt;&gt;&gt; print(f\"The dir after removal is: {os.listdir(os.getcwd())}\")<\/pre>\n<p>removedirs() doesn\u2019t return any value.<\/p>\n<h3>46. rename(src,dst) method in Python<\/h3>\n<p>rename() renames a file or directory. If the destination is a file or a directory that already exists, it raises an OSError.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; print(f\"The dir is: {os.listdir(os.getcwd())}\u201d)\r\n&gt;&gt;&gt; os.rename(\"tutorialsdir\",\"tutorialsdirectory\")\r\n&gt;&gt;&gt; print(\u201cSuccessfully renamed\u201d)\r\n&gt;&gt;&gt; print(f\"The dir is: {os.listdir(os.getcwd())}\")<\/pre>\n<p>rename() doesn\u2019t return any value.<\/p>\n<h3>47. renames(old,new) method in Python<\/h3>\n<p>renames() Python os Module renames directories and files recursively.<\/p>\n<p>It is like os.rename(), but it also moves a file to a directory, or a whole tree of directories, that do not already exist.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; print(\"Current directory is: { os.getcwd()}\")\r\n&gt;&gt;&gt; print(\"The dir is: { os.listdir(os.getcwd())}\")\r\n&gt;&gt;&gt; os.renames(\"aa1.txt\",\"newdir\/aanew.txt\")\r\n&gt;&gt;&gt; print(\"Successfully renamed\u201d)\r\n&gt;&gt;&gt; print(f\"The dir is: {os.listdir(os.getcwd())}\")<\/pre>\n<p>renames() does not return any value.<\/p>\n<h3>48. rmdir(path) method in Python<\/h3>\n<p>Python os Module rmdir() removes the directory path specified. If the directory isn\u2019t empty, however, it raises an OSError.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; print(f\"the dir is: { os.listdir(os.getcwd())}\")\r\n&gt;&gt;&gt; os.rmdir(\"mydir\")\r\n&gt;&gt;&gt; print(f\"the dir is: { os.listdir(os.getcwd())}\"<\/pre>\n<p>rmdir() doesn\u2019t return any value.<\/p>\n<h3>49. stat(path) method in Python<\/h3>\n<p>This Python os Module performs a stat system call on the specified path.<br \/>\nThese are the members of the stat structure:<\/p>\n<ul>\n<li>st_mode \u2212 protection bits<\/li>\n<li>st_ino \u2212 inode number<\/li>\n<li>st_dev \u2212 device<\/li>\n<li>st_nlink \u2212 number of hard links<\/li>\n<li>st_uid \u2212 user ID of the owner<\/li>\n<li>st_gid \u2212 group ID of owner<\/li>\n<li>st_size \u2212 size of file, in bytes<\/li>\n<li>st_atime \u2212 time of most recent access<\/li>\n<li>st_mtime \u2212 time of most recent content modification<\/li>\n<li>st_ctime \u2212 time of most recent metadata change.<\/li>\n<\/ul>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; statinfo = os.stat('a2.py')\r\n&gt;&gt;&gt; print(statinfo)<\/pre>\n<h3>50. stat_float_times([newvalue]) method in Python<\/h3>\n<p>stat_float_times() Python os Module decides whether stat_result denotes time stamps as float objects.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; import os, sys\r\n&gt;&gt;&gt; statinfo = os.stat('a2.py')\r\n&gt;&gt;&gt; print(statinfo)\r\n&gt;&gt;&gt; statinfo = os.stat_float_times()\r\n&gt;&gt;&gt; print(statinfo)<\/pre>\n<h3>51. statvfs(path) method in Python<\/h3>\n<p>Python os Module statvfs() executes a statvfs system call on the specified path.<\/p>\n<p>The structure has the following members:<\/p>\n<ul>\n<li>f_bsize \u2212 preferred file system block size<\/li>\n<li>f_frsize \u2212 fundamental file system block size<\/li>\n<li>f_blocks \u2212 total number of blocks in the filesystem<\/li>\n<li>f_bfree \u2212 total number of free blocks<\/li>\n<li>f_bavail \u2212 free blocks available to non-super user<\/li>\n<li>f_files \u2212 total number of file nodes<\/li>\n<li>f_ffree \u2212 total number of free file nodes<\/li>\n<li>f_favail \u2212 free nodes available to non-super user<\/li>\n<li>f_flag \u2212 system dependent<\/li>\n<li>f_namemax \u2212 maximum file name length<\/li>\n<\/ul>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; stinfo = os.statvfs('a1.py')\r\n&gt;&gt;&gt; print(stinfo)<\/pre>\n<h3>52. symlink(src,dst) method in Python<\/h3>\n<p>symlink() composes a symbolic link dst that points to the source.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt;src = '\/usr\/bin\/python'\r\n&gt;&gt;&gt; dst = '\/tmp\/python'\r\n&gt;&gt;&gt; os.symlink(src, dst)<\/pre>\n<p>symlink() returns no value.<\/p>\n<h3>53. tcgetpgrp(fd) method in Python<\/h3>\n<p>This Python os Module returns the process group linked to the terminal specified by fd, which is an open file descriptor, and is returned by os.open().<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; print(f\"Current working dir : { os.getcwd()}\")\r\n&gt;&gt;&gt; fd = os.open(\"\/dev\/tty\",os.O_RDONLY)\r\n&gt;&gt;&gt; f = os.tcgetpgrp(fd)\r\n&gt;&gt;&gt; print(f\"the process group associated is: {f}\")\r\n&gt;&gt;&gt; os.close(fd)<\/pre>\n<p>tcgetpgrp() returns the process group.<\/p>\n<h3>54. tcsetpgrp(fd, pg) method in Python<\/h3>\n<p>Python os Module tcsetpgrp() sets the process group linked to the terminal specified by fd, which is an open file descriptor, and is returned by os.open(), to pg.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; print(f\"Current working dir : { os.getcwd()}\")\r\n&gt;&gt;&gt; fd = os.open(\"\/dev\/tty\",os.O_RDONLY)\r\n&gt;&gt;&gt; f = os.tcgetpgrp(fd)\r\n&gt;&gt;&gt; print(f\"the process group associated is: {f}\")\r\n&gt;&gt;&gt; os.tcsetpgrp(fd,2672)\r\n&gt;&gt;&gt; print(\"done\")\r\n&gt;&gt;&gt; os.close(fd)<\/pre>\n<p>tcsetpgrp() returns no value.<\/p>\n<h3>55. tempnam([dir[, prefix]]) method in Python<\/h3>\n<p>tempnam() Python os Module returns a unique path name reasonable enough to create a temporary file.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; tmpfn = os.tempnam('\/tmp\/tutorialsdir,'tuts1')<\/pre>\n<p>tempnam() returns a unique path.<\/p>\n<h3>56. tmpfile() method in Python<\/h3>\n<p>tmpfile() will return a new temporary file object, opening it in update mode (w+b).<\/p>\n<p>This file has zero directory entries linked to it, and will automatically delete when no descriptors are available.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; tmpfile = os.tmpfile()\r\n&gt;&gt;&gt; tmpfile.write('Temporary newfile is here.....')\r\n&gt;&gt;&gt; tmpfile.seek(0)\r\n&gt;&gt;&gt; print(tmpfile.read())\r\n&gt;&gt;&gt; tmpfile.close()<\/pre>\n<h3>57. tmpnam() method in Python<\/h3>\n<p>tmpnam() will return a unique path name reasonable enough to create a temporary file.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; tmpfn = os.tmpnam()\r\n&gt;&gt;&gt; print(f\"This is the unique path: {tmpfn}\")<\/pre>\n<h3>58. ttyname(fd) method in Python<\/h3>\n<p>ttyname() Python os Module will return a string that denotes the terminal device linked to the descriptor fd.<\/p>\n<p>If it isn\u2019t linked to a terminal device, it raises an exception.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; print(f\"Current working dir : { os.getcwd()}\")\r\n&gt;&gt;&gt; fd = os.open(\"\/dev\/tty\",os.O_RDONLY)\r\n&gt;&gt;&gt; p = os.ttyname(fd)\r\n&gt;&gt;&gt; print(f\"the terminal device associated is: {p}\")\r\n&gt;&gt;&gt; os.close(fd)<\/pre>\n<p>ttyname() returns a string that denotes the terminal device.<\/p>\n<h3>59. unlink(path) method in Python<\/h3>\n<p>This Python os Module will remove the specified file path. If it is a directory, it raises an OSError.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; print(f\"The dir is: { os.listdir(os.getcwd())}\")\r\n&gt;&gt;&gt; os.unlink(\"aa.txt\")\r\n&gt;&gt;&gt; print(f\"The dir after removal of path : { os.listdir(os.getcwd())}\")<\/pre>\n<p>unlink() doesn\u2019t return any value.<\/p>\n<h3>60. utime(path,times) method in Python<\/h3>\n<p>Python os Module utime() sets the access and modified times of the file at the specified path.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; stinfo = os.stat('a2.py')\r\n&gt;&gt;&gt; print(stinfo)\r\n&gt;&gt;&gt; print(f\"access time of a2.py: { stinfo.st_atime }\")\r\n&gt;&gt;&gt; print(f\"modified time of a2.py: { stinfo.st_mtime }\")\r\n&gt;&gt;&gt; os.utime(\"a2.py\",(1330712280, 1330712292))<\/pre>\n<p>utime() returns no value.<\/p>\n<h3>61. walk(top[, topdown=True[, onerror=None[, followlinks=False]]])<\/h3>\n<p>walk() creates file names in a directory tree. It does so by walking the tree either bottom-up or top-down.<\/p>\n<p>It has the following parameters:<\/p>\n<ol>\n<li>top \u2212 Each directory rooted at directory<\/li>\n<li>topdown \u2212 If topdown is True, or not specified, it scans directories top-down.<\/li>\n<li>onerror \u2212 This may show an error to continue with the walk, or may raise an exception to abort the walk.<\/li>\n<li>followlinks \u2212 This will visit directories that symlinks points to, that is, if set to true.<\/li>\n<\/ol>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; for root, dirs, files in os.walk(\".\", topdown=False):<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">for name in files:<br \/>\nprint(os.path.join(root, name))<br \/>\nfor name in dirs:<br \/>\nprint(os.path.join(root, name))<\/div>\n<h3>62. write(fd,str) method in Python<\/h3>\n<p>This Python os Module will write the specified string to descriptor fd. It returns the number of bytes that it actually wrote.<\/p>\n<p>Sample usage:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; fd = os.open(\"f1.txt\",os.O_RDWR|os.CREAT)\r\n&gt;&gt;&gt; ret = os.write(fd,\"This is test\")\r\n&gt;&gt;&gt; print(f\"the number of bytes written: {ret}\")\r\n&gt;&gt;&gt; print(\"written successfully\")\r\n&gt;&gt;&gt; os.close(fd)<\/pre>\n<p>So, this was all about the Python os Module. Hope you like our explanation.<\/p>\n<h3>Python Interview Questions on OS Modules<\/h3>\n<ol>\n<li>What is the OS Module in Python?<\/li>\n<li>How to open an OS Module in Python?<\/li>\n<li>What is the use of the OS Module in Python?<\/li>\n<li>What is the OS Path Module in Python?<\/li>\n<li>What is the import OS SYS in Python?<\/li>\n<\/ol>\n<h3>Conclusion<\/h3>\n<p>Hence, we cover all the Python os module. This will allow you to work your way around the directories without any problem.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial on Python os Module, we will get closer to the os module and its methods. Moreover, we will study syntax and examples of os Module in Python Programming Language. So, let&#8217;s&#46;&#46;&#46;<\/p>\n","protected":false},"author":5,"featured_media":36541,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[16502,16501,10687,10750],"class_list":["post-11112","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-list-of-python-os-module","tag-os-module-in-python","tag-python-modules","tag-python-os-modules"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>List of 63 Python os Module with Syntax &amp; Examples (Latest) - DataFlair<\/title>\n<meta name=\"description\" content=\"Python os Module: Learn what are Python os Modules and Access list of 63 os modules in Python like access(path,mode), chdir(path), chflags(path,flags) etc\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/python-os-module\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"List of 63 Python os Module with Syntax &amp; Examples (Latest) - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Python os Module: Learn what are Python os Modules and Access list of 63 os modules in Python like access(path,mode), chdir(path), chflags(path,flags) etc\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/python-os-module\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-03-19T01:02:11+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-24T09:19:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Python-os-Module-01-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"17 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"List of 63 Python os Module with Syntax &amp; Examples (Latest) - DataFlair","description":"Python os Module: Learn what are Python os Modules and Access list of 63 os modules in Python like access(path,mode), chdir(path), chflags(path,flags) etc","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/python-os-module\/","og_locale":"en_US","og_type":"article","og_title":"List of 63 Python os Module with Syntax &amp; Examples (Latest) - DataFlair","og_description":"Python os Module: Learn what are Python os Modules and Access list of 63 os modules in Python like access(path,mode), chdir(path), chflags(path,flags) etc","og_url":"https:\/\/data-flair.training\/blogs\/python-os-module\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2018-03-19T01:02:11+00:00","article_modified_time":"2026-04-24T09:19:03+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Python-os-Module-01-1.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"17 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/python-os-module\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/python-os-module\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823"},"headline":"List of 63 Python os Module with Syntax &amp; Examples (Latest)","datePublished":"2018-03-19T01:02:11+00:00","dateModified":"2026-04-24T09:19:03+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-os-module\/"},"wordCount":4005,"commentCount":2,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-os-module\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Python-os-Module-01-1.jpg","keywords":["List of Python os Module","Os Module in Python","Python Modules","Python os Modules"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/python-os-module\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/python-os-module\/","url":"https:\/\/data-flair.training\/blogs\/python-os-module\/","name":"List of 63 Python os Module with Syntax &amp; Examples (Latest) - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-os-module\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-os-module\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Python-os-Module-01-1.jpg","datePublished":"2018-03-19T01:02:11+00:00","dateModified":"2026-04-24T09:19:03+00:00","description":"Python os Module: Learn what are Python os Modules and Access list of 63 os modules in Python like access(path,mode), chdir(path), chflags(path,flags) etc","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/python-os-module\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/python-os-module\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/python-os-module\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Python-os-Module-01-1.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Python-os-Module-01-1.jpg","width":1200,"height":628,"caption":"List of 63 Python os Module with Syntax &amp; Examples (Latest)"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/python-os-module\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Python Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/python\/"},{"@type":"ListItem","position":3,"name":"List of 63 Python os Module with Syntax &amp; Examples (Latest)"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team creates expert-level guides on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our goal is to empower learners with easy-to-understand content. Explore our resources for career growth and practical learning.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam1\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/11112","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=11112"}],"version-history":[{"count":22,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/11112\/revisions"}],"predecessor-version":[{"id":147834,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/11112\/revisions\/147834"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/36541"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=11112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=11112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=11112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}