Several magic commands for jupyter development tools in python3

1 %run myscript/hello.py

can execute the PY file in a certain directory

2 Test time, it will automatically execute a certain number of times, and then average:
%timeit L=[i*2 for i in range(100)]
7.42 µs ± 128 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)


can also be multiple lines:
  %%timeit
l=[]
for n in range(100):
    l.append(n**2)

use The thing is that two %

can also be executed only once:
%time L=[i*2 for i in range(100)]

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326107718&siteId=291194637