죄송합니다. 저는 파이썬 언어의 초보자입니다.이 문제는 꽤 오래 걸렸습니다. 실제로, 내림차순으로 만들고 목록을 오름차순으로 만들고 싶습니다. 내림차순과 오름차순의 모듈.하지만 나는 그것을 얻을 수 없었다. 주요 파이썬 파일이 pythonaslab.py과 상승에 대한 모듈과 하강이 selectionmodule.py..the 코드 :내 모듈이로드되지 않습니다.
이가 selectionmodule입니다 :
import pythonaslab
def ascendingselection():
for q in range(len(b)):
w=q+1
for w in range(len(b)):
if b[q]>b[w]:
f=b[q]
b[q]=b[w]
b[w]=f
print b
def descendingselection():
for q in range(len(b)):
w=q+1
for w in range(len(b)):
if b[q]<b[w]:
f=b[q]
b[q]=b[w]
b[w]=f
print b
그리고이 주 파일입니다, the pythonaslab :
import selectionmodule
a = int(input())
b = [int(input()) for _ in range(a)]
print b
print "1.ascending 2.descending"
c=input()
if c==1:
selectionmodule.ascendingselection()
if c==2:
selectionmodule.descendingselection()
당신은 내가이 모든 오류의 원인은 어디 있는지 지적 해 줄 수 있습니까?
Traceback (most recent call last):
File "E:\Coding\pythonaslab.py", line 1, in <module>
import selectionmodule
File "E:\Coding\selectionmodule.py", line 1, in <module>
import pythonaslab
File "E:\Coding\pythonaslab.py", line 16, in <module>
selectionmodule.descendingselection()
AttributeError: 'module' object has no attribute 'descendingselection'
* 무슨 * 에러가 발생합니까? 전체 추적을 게시 할 수 있습니까? –
디렉토리에'__init __. py' 파일이 있습니까? – immortal
역 추적 (마지막으로 가장 최근 통화) : 파일 "E : \의 pythonaslab.py 코딩 \" 수입 selectionmodule 파일에서, 라인 1 "E : \ 코딩 \의 selectionmodule.py", 라인 1, 수입에 pythonaslab 파일 "E : \의 pythonaslab.py 코딩 \") ( selectionmodule.descendingselection에서, 라인 (16)을 AttributeError : '모듈'개체가 어떤 속성 'descendingselection' –
Ball