简体   繁体   English

如何在 python 中运行脚本?

[英]How to run scripts in python?

How to run cmd codes like pip install matplotlib in python?如何在 python 中运行 cmd 代码,如pip install matplotlib matplotlib? I tried to use Stash , but it costs too much time and it cannot be run if I have a UIView .我尝试使用Stash ,但是如果我有UIView ,它会花费太多时间并且无法运行。 So, can someone help me?那么,有人可以帮助我吗?

Use os.system to do that.使用os.system来做到这一点。 You use say os.system(“your command”)你用说os.system(“your command”)

Oh, I found how to do that!哦,我找到了怎么做! Use os.system(“pip install matplotlib”) to do that!使用os.system(“pip install matplotlib”)来做到这一点!

My code:我的代码:

import os
os.system(“pip install matplotlib”)

:DDDD :DDDD

Source: geeksforgeeks资料来源: geeksforgeeks

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM