【发布时间】:2014-02-20 13:38:06
【问题描述】:
这是错误:
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 中没有定义“执行”函数,但我在另一个项目中使用了相同的精确代码(文字复制粘贴情况)并且它工作 100%!我不知道我做错了什么,任何帮助将不胜感激!
【问题讨论】:
-
您希望在
x.execute()行发生什么?x是str -
你正在用 x = raw_input (">>>") 覆盖 x
-
我很确定代码从来没有工作过,不管大写字母是否有把握......
-
DSM,什么代码不起作用?你的意思是DefaultX? DefaultX 是我制作的自定义模块。
-
@user3230819:我的意思是
x的冲突不是突然出现的。
标签: python python-import function