본문 바로가기

그 외 코드/Python

파이썬 %명령어, 매직명령어

728x90
반응형

%run

%run hellow.py #py파일 실행

Hellow Python!


%timelit

import numpy as np
a = np.random.randn(100,100)
%timeit np.dot(a.T,a) #실행시간 보기

62 µs ± 3.47 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)


%pwd

%pwd #파일(디렉토리) 경로 보기

'C:\NEW'


%cd

%cd new1 #폴더(디렉토리) 경로 이동

C:\NEW\new1

%cd .. #이전 디렉토리로 이동

C:\NEW


%who & %whos

%who #변수 리스트

a add_numbers an_apple an_tree b datetime f g h
i l np s sys

%whos #변수값 등 info


%lsmagic

%magic : 매직 명령어 도움말

%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.

728x90
반응형