2016-12-28 76 views
0

考慮在IPython的筆記本下面幾行:寫作乳膠在IPython的輸出

B=1.0e5 # in Gauss 
fce = 1.80e6 * B 
print "Electron gyrofrequency $f_{ce}$= %0.5e " %(fce) 

我不能得到$ {F_ CE} $在其乳膠的形式打印。我也試過:

 from IPython.display import display, Math, Latex 
    display ("Electron gyrofrequency" + Math(r'f_{ce}') + "= %0.5e " %(fce)) 

我得到了一個錯誤:

TypeError: cannot concatenate 'str' and 'Math' objects 
+0

你試過'乳膠( 「Electron gyrofrequency $ f_ {ce} $ =%0.5e」%fce)' – cel

+0

這很奏效。請讓它成爲答案,我可以接受它 – wander95

回答

0

您可以通過它傳遞給Latex構造使全乳膠字符串:

from IPython.display import Latex 

B=1.0e5 # in Gauss 
fce = 1.80e6 * B 

Latex("Electron gyrofrequency $f_{ce}$= %0.5e " % fce) 
+0

我剛纔問了一個問題:http://stackoverflow.com/questions/41365927/ipython-output-missing – wander95