【问题标题】:How can I run files on external terminal?如何在外部终端上运行文件?
【发布时间】:2022-01-21 12:43:09
【问题描述】:

我试图用 Python 制作一个生成随机密码的程序,我想在 Windows 终端而不是 Visual Studio Code 的内部终端上运行这个程序。

这是代码:

import random

lunghezza = int(input("inserisci la lunghezza della password"))  # insert password lenght

s = "abcdefghijklmnopqestuvwxyz1234567890"

p = "".join(random.sample(s, lunghezza)) 
 # lunghezza means lenght

print(p)

【问题讨论】:

  • python3.exe yourpythonfile.py ... 在控制台中 ...

标签: python terminal


【解决方案1】:

打开 Windows 终端,导航到文件的目录(您可以通过在 Visual Studio 的终端中输入 pwd 找到它)并执行文件输入:

python yourfilename.py

python3 yourfilename.py

【讨论】:

    【解决方案2】:

    要在终端中执行 Python 文件,您有多种选择:
    1-如果您在 Windows 中:python MyPythonFile.py
    2-如果您使用的是 Linuxpython3 MyPythonFile.py


    如果你想使用python 2.x,你需要使用python2 MyPythonFile.py,如果你使用的是Linux

    【讨论】:

      猜你喜欢
      • 2020-02-22
      • 1970-01-01
      • 2013-12-23
      • 2020-11-09
      • 2016-09-23
      • 2019-06-11
      • 1970-01-01
      • 1970-01-01
      • 2020-05-09
      相关资源
      最近更新 更多