Python Can replace shell Do you ? Many people are curious . The answer given by Xiaobian here is yes ,Python Is an easy to learn programming language , Powerful , Can be used instead of shell.
Shell It's a use. C A program written in a language , It is used by users Linux Or class Unix The bridge .
Shell It's a command language , Another programming language ;shell Refers to an application , This application provides an interface , Users access the services of the operating system kernel through this interface .
Python Built in OS Modules provide a wealth of ways to interact with the operating system , Can learn in depth Python Of OS modular ;Python It was born to simplify the operation and maintenance workload , Finally, it developed into a universal language .
use Python To replace shell There is no problem ,Python Easy to learn , Grammar is simple , It's fast to learn , You can also use Python To do automatic operation and maintenance .
Shell The function of Python Can be used to achieve , And the amount of code is small 、 Better structure 、 Better readability ; and Python Realizable functions shell But not necessarily , For example, it is used for network communication in operation and maintenance socket modular 、 be used for web Of Django frame 、 For performance acquisition psutil modular , and shell It's highly dependent on the command of the operating system ,Python These can be circumvented to a greater extent .
also ,shell Medium IDE It's a big problem , although Python The native IDE Just so so? , But a third party IDE It's very powerful , Although not with Microsoft's Virtual Studio Comparable , But also can satisfy completely Python Development requirements .
To talk about Python The question of efficiency ,Python Support multiple processes 、 Multithreading and coroutines , Program concurrency is in shell Above .Python The core modules of are basically C To achieve , So it's more efficient , To make a long story short Python It can replace shell Of , however shell May not replace Python.