[英]Could someone explain to me what I'm doing wrong in this Python Code and help me figure it out?
Here is the error: 这是错误:
Traceback (most recent call last):
File "/home/endergreen/PyOS/SHOE/C.pyx", line 24, in <module>
x.execute()
AttributeError: 'str' object has no attribute 'execute'
Here is the set of code: 这是代码集:
#!/usr/bin/env python
import os as os
import sys as sys
import time as time
import DefaultX as x
def setup():
execfile ("Setup.pyx")
print ("Running...")
def start():
execfile ("/HDD/BOOT.pyrx")
print ("Running...")
def end():
print ("Stopping...")
time.sleep (3)
x.machine_start
x = raw_input (">>>")
if x == 'setup':
x.setup()
if x == 'start':
x.start()
if x == 'execute':
x.execute()
if x == 'chkfile':
x.chkfile()
if x == 'chkinstall':
x.chkdisk()
if x == 'commands':
x.cmds()
else:
print ("Unsupported Command")
raw_input ("Press [Enter] to continue...")
execfile ("C.pyx")
The error appears to be saying that the 'execute' function has not been defined in DefaultX.py, but I've used the SAME EXACT CODE (a literal copy-paste situation) in another project and it worked 100%! 错误似乎是在“ DefaultX.py”中尚未定义“执行”功能,但是我在另一个项目中使用了“相同的精确代码”(按字面意思复制粘贴的情况),它的工作效率为100%! I have no clue what I'm doing wrong and any help would be greatly appreciated!
我不知道我在做什么错,任何帮助将不胜感激!
You have conflicting definitions of x
: 您对
x
定义有冲突:
import DefaultX as x
x = raw_input (">>>")
Change one of them. 更改其中之一。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.