【发布时间】:2019-01-11 15:03:56
【问题描述】:
这是 python 中的辅助命令行,我当然希望为自己添加自定义内容,并且正在添加 IP 搜索器。这个错误已经有一段时间了,似乎无法弄清楚,并且它对启动我的提示至关重要。任何提示表示赞赏,美好的一天。
from cmd import Cmd
import pyautogui as pag #Future#
import time #Debugging/Future#
import sys,os
clear = lambda : os.system('cls')
#############################################
from colorama import init
from ctypes.test.test_pickling import name
init(strip=not sys.stdout.isatty()) # strip colors if stdout is redirected
from termcolor import cprint
from pyfiglet import figlet_format
##############################################
class MyPrompt(Cmd):
@staticmethod
def do_lineage(self):
"""Switch to Lineage 2 Helper"""
print("Switching to Lineage 2 Helper....")
os.system(r"python C:\Users\David\eclipse-workspace\CMD\src\L2.py")
@staticmethod
def do_ip(self):
"""IP"""
print("Switching to IP stuff.... ")
os.system(r"python C:\Users\David\eclipse-workspace\CMD\src\Play.py")
@staticmethod
def do_quit(self):
"""Quits the program."""
print("Quitting...")
raise SystemExit
@staticmethod
def do_Movies(self,num):
"""1-3 different sites, or all for """
if num == 1:
print("https://genvideos.org")
os.system("C:\Program Files (x86)\Google\Chrome\Application\chrome --app=https://genvideos.org")
if num == 2:
print("https://www3.gomovies.sc")
os.system("C:\Program Files (x86)\Google\Chrome\Application\chrome --app=https://www3.gomovies.sc")
if num == 3:
print("https://vioozgo.org/")
os.system("C:\Program Files (x86)\Google\Chrome\Application\chrome --app=google.com")
if num == "all":
print("https://genvideos.org")
print("https://www3.gomovies.sc")
print("https://vioozgo.org/")
os.system("C:\Program Files (x86)\Google\Chrome\Application\chrome --app=google.com")
if __name__ == '__main__':
clear()
prompt = MyPrompt()
prompt.prompt = '> '
prompt.cmdloop(cprint(figlet_format('--------\nHelper\n--------', font='smslant'), "yellow"))
我的错误:
Traceback (most recent call last):
File "C:\Users\David\eclipse-workspace\CMD\src\Cmdd.py", line 1, in <module>
from cmd import Cmd
ImportError: cannot import name 'Cmd'
这是以前的工作,必须改变一些东西。我哪里错了?
【问题讨论】:
-
你有一些名为
cmd的其他模块,Python 正在寻找它而不是内置模块。 -
@kindall 我似乎找不到这个 cmd。我创建了一个单独的文件来测试基础知识,似乎无法导入 cmd 的 Cmd 子类。奇怪...
-
感谢@kindall - 在我的例子中,我正在运行我在 Code Maven 上找到的一些测试代码,并且愚蠢地将我的测试文件命名为“cmd.py”。一旦我将文件重命名为其他文件,它运行良好。
标签: python eclipse python-3.x inner-classes