简体   繁体   English

Python os.system() 在 windows 上使用 cmd,我可以通过任何方式更改为我的 Z1D41C5853AF59D137D6083AA258B5C42Z

[英]Python os.system() uses cmd on windows, any ways I can change to my ubuntu terminal?

I feel uncomfortable using cmd and I want to use commands for my python scripts, wondering if there is any way to not use cmd for os.system() and instead changes that to my ubuntu terminal. I feel uncomfortable using cmd and I want to use commands for my python scripts, wondering if there is any way to not use cmd for os.system() and instead changes that to my ubuntu terminal. Thanks谢谢

Per the Python docs , os.system(<command>) executes <command> in a subshell, which is system dependent.根据Python docsos.system(<command>)在子shell中执行<command> ,这取决于系统。 There is no way to make os.system() run a Windows specific command as a Unix equivalent.没有办法让os.system()运行 Windows 特定命令作为 Unix 等效命令。 You may be interested in Python's sys module你可能对 Python 的sys 模块感兴趣

If you edit your question with more specific details as to what commands you are trying to run I might be able to provide better help.如果您使用有关您尝试运行的命令的更具体细节来编辑您的问题,我可能会提供更好的帮助。

os.system() normally runs system commands depending the OS you are running the script. os.system() 通常根据您运行脚本的操作系统运行系统命令。 However, you can read this article on Stackoverflow or try to follow further steps to setup an effective environment for Python on Ubuntu on Windows.但是,您可以阅读有关Stackoverflow的这篇文章,或尝试按照进一步的步骤为 Windows 上的 Ubuntu 上的 Python 设置有效环境。

  1. Install Bash on Windows在 Windows 上安装 Bash
  2. Check for updates检查更新
  3. Check out the REPL查看 REPL
  4. Install Pip安装Pip
  5. Install VirtualEnv安装 VirtualEnv
  6. Install VirtualEnvWrapper安装 VirtualEnvWrapper
  7. Create your first virtualenv创建你的第一个 virtualenv
  8. Configure bashrc to keep it working More detailes here配置 bashrc 以使其保持工作更多详细信息here

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

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