What role does the module sys play in Python?

Asked 1 years ago, Updated 1 years ago, 76 views

import sys

src = sys.argv[1] dst = sys.argv[2]

f = open(src) tab_content = f.read() f.close()

space_content = tab_content.replace("\t", " "*4)

f = open(dst, 'w') f.write(space_content) f.close()

It's a code that changes the tab part of a text file to four spaces

I came out looking at the module, and I know that the module is for the function that I created to be used

I understand the basic support of the sys module from Py-Sun, but I don't know what role it plays

python python-2.7

2022-09-21 15:50

2 Answers

I think the official document description is the most accurate.

sys — System-specific parameters and functions

This module provides access to some variables used or maintained by the interpreter and to functions that interact strongly with the interpreter. It is always available.


2022-09-21 15:50

To put it simply, the system... It can be an operating system, and more profoundly, it's mainly used to influence hardware memory.

As you used in the body code, starting with getting the print, executing the OS command, or... I think you'll use it the most in this area.

Your operating system may be Windows or Linux, but the commands used by your operating system... It's going to be a command from cmd in Windows, and it's going to be it's going to be a shell command on Linux. Required when using these commands.


2022-09-21 15:50

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.