Jupyter NoteBook 使用
data = [i * 2 for i in range(100)]
data[:10]
[0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
len(data)
100
Jupyter NoteBook 魔法命令
%run [path] 可以运行制定路径的py文件python 代码 , 并且可以调用对应文件的方法
%time L = [i * 2 for i in range(100)]: 作用 : 计算方法或者代码块的性能
%time L = [i * 2 for i in range(1000)]
Wall time: 0 ns
%%time
L = []
for i in range(1000):
L.append(i ** 2)
Wall time: 0 ns
%lsmagic
Available line magics:
%alias %alias_magic %autoawait %autocall %automagic %autosave %bookmark %cd %clear %cls %colors %conda %config %connect_info %copy %ddir %debug %dhist %dirs %doctest_mode %echo %ed %edit %env %gui %hist %history %killbgscripts %ldir %less %load %load_ext %loadpy %logoff %logon %logstart %logstate %logstop %ls %lsmagic %macro %magic %matplotlib %mkdir %more %notebook %page %pastebin %pdb %pdef %pdoc %pfile %pinfo %pinfo2 %pip %popd %pprint %precision %prun %psearch %psource %pushd %pwd %pycat %pylab %qtconsole %quickref %recall %rehashx %reload_ext %ren %rep %rerun %reset %reset_selective %rmdir %run %save %sc %set_env %store %sx %system %tb %time %timeit %unalias %unload_ext %who %who_ls %whos %xdel %xmode
Available cell magics:
%%! %%HTML %%SVG %%bash %%capture %%cmd %%debug %%file %%html %%javascript %%js %%latex %%markdown %%perl %%prun %%pypy %%python %%python2 %%python3 %%ruby %%script %%sh %%svg %%sx %%system %%time %%timeit %%writefile
Automagic is ON, % prefix IS NOT needed for line magics.
%run?