更新时间:2023-02-02 22:11:44
我不知道你想复制的pure Python程度,但是你可以委托整个管道对 shell 的操作.
I don't know the degree of pure Python you want to use for the copy, but you can just delegate the entire pipe operation to the shell.
subprocess.Popen('mysqldump -h localhost -P 3306 -u -root mydb | mysql -h localhost -P 3306 -u root mydb2', shell=True)
这应该与您在 shell 上运行时的工作方式相同.
This should work the same way it works when you run it on the shell.