【发布时间】:2021-05-06 20:07:27
【问题描述】:
我的 python 代码只有在放入 Visual Studio Code 时才能运行。代码仍然可以运行,但是当我点击脚本运行它时,它不起作用,当我使用命令运行它时,它也不起作用。
# importing the module
import time
import wikipedia
import io
# looks for a random page and stores the topic in random
random = wikipedia.random(pages=1)
#searches for the topic and stores it in wiki
wiki = wikipedia.summary((random), sentences = 1)
# print the output of wiki
file = open("test.txt", "w")
file.write(wiki)
file.close
我也有一个 AutoHotkey 脚本来运行它,但这也不起作用。
【问题讨论】:
-
你能分享它引发的错误吗?
-
从命令行运行脚本时是否有任何消息?
-
它不起作用是什么意思?什么都没有,或者你得到一个错误?你的代码看起来不错我猜你的 python 路径错误或类似的东西
标签: python python-3.x visual-studio-code