How to give input streams in python?

后端 未结 2 1834
既然无缘
既然无缘 2021-01-21 09:54

i\'m uninstall some packages in Linux via python os module my code like

def uninstallZdev():
    print \'Uninstallation as a Super User\'
    system(\'apt-get re         


        
2条回答
  •  既然无缘
    2021-01-21 10:27

    Use the -y to automate apt-get. Thus, you don't have to simulate the "y"-press.

    Btw, I'd recommend using the subprocess-module, especially if you're planing to work with stdin/stdout.

    And: be carefull! You seem to run this as root, or with sudo. If xxx happens to be libc-bin for some reason, you'll have fun restoring your system.

提交回复
热议问题