这是错误:
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'
以下是一组代码:
#!/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")
错误似乎是说在DefaultX.py中没有定义'execute'函数,但是我在另一个项目中使用了相同的CODE代码(文字复制粘贴情况)并且它100%工作!我不知道我做错了什么,非常感谢任何帮助!
答案 0 :(得分:5)
您对x
:
import DefaultX as x
x = raw_input (">>>")
更改其中一个。