0
Hii! 나는 내 기능의 실행 시간을 얻고 싶다. (test (G)). 내가 타이머를 사용할 때 내 개체 유형을 써야합니다. "test (% ??)"% G 여기 DiGraph입니다. 어떻게해야합니까?DiGraph()를 반복 할 때 TypeError가 발생했습니다.
from networkx import nx
def test(G):
for e in G.edges_iter():
print(e)
if __name__=='__main__':
from timeit import Timer
G = nx.DiGraph()
G.add_edges_from([(1,2),(4,5)])
t = Timer("test(% ??)"%G,"from __main__ import test")
print(t.timeit(1))
감사합니다. 왜냐하면 필자는 수입 명세서를 수정해야 작동하기 때문에 이상합니다. 그러나 "networkx import nx"와 "nx as import networkx"의 차이점은 무엇입니까 ?? – masti
'from networkx import nx'는'networkx' 모듈이'nx' 함수를 포함해야 함을 의미합니다. 하지만 당신은 그것을 원하지 않는다. 당신은 _itself_'nx' 모듈을 호출하기를 원한다. – katrielalex