这个是因为你的语法不复合PEP8 Python 编码规范,比如方法名有大写,类名小写,等等,你可以把鼠标指到那个波浪线,会有提示的。
当我们在代码里面有语法错误,或者代码编写不符合 pep8 代码规范时,鼠标选择有问题的代码,就会自动弹出小灯泡,这个灯泡是有颜色之分的,如果是红灯泡,一般都是语法问题,如果不处理会影响代码运行。而如果是黄灯泡,就只是一个提示,提示你代码不规范等,并不会影响程序的运行。
虽然这个灯泡,是出于善意之举,但我认为它确实有点多余(可能是我个人没有使用它的习惯),要是语法错误会有红色波浪线提示。你可能会说灯泡不仅起到提示的作用,它还可以自动纠正代码,我个人感觉并没有人工校正来得效率,来得精准。
用一下代码解决:import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import interp1d
import scipy.stats as st
sim = st.gamma(1,loc=0,scale=0.8) # Simulated
obs = st.gamma(2,loc=0,scale=0.7) # Observed
x = np.linspace(0,4,1000)
simpdf = sim.pdf(x)
obspdf = obs.pdf(x)
plt.plot(x,simpdf,label='Simulated')
plt.plot(x,obspdf,'r--',label='Observed')
plt.title('PDF of Observed and Simulated Precipitation')
plt.legend(loc='best')
plt.show()
plt.figure(1)
simcdf = sim.cdf(x)
obscdf = obs.cdf(x)
plt.plot(x,simcdf,label='Simulated')
plt.plot(x,obscdf,'r--',label='Observed')
plt.title('CDF of Observed and Simulated Precipitation')
plt.legend(loc='best')
plt.show()
# Inverse CDF
invcdf = interp1d(obscdf,x)
transfer_func = invcdf(simcdf)
plt.figure(2)
plt.plot(transfer_func,x,'g-')
plt.show()
你是直接在idle里面运行了
idle里最多运行一个代码块,所以你后面的东西不在if里面,就不能同时运行了,你如果要强行这么做的话可以这样:
#先用一个if True,接下来所有东西都算是在这个if里面的了if True:
#开始写代码,就用你这个例子
if a > 4:
print "ss"
print "kk"