Python - Spyder:语法无效 - 为什么?

Python - Spyder: Invalid syntax - Why?

我的语法无效:

Upper_Stress=10 #Upper stress limit
Lower_Stress=0 #Lower stress limiy
Number_tests =[]
Normalized_Stress=[]
NumberStressLevels = [] #of stress levels for each component
base  = [0.5,0.5,0.5] #True Value: Theta_0, theta_1 and Sigma
Time_Scale =(np.exp(base[0]+base[1]*0.25)  #Generate failure time with scale = exp(alpha)
Time_Shape =(1/base[2]) #Generate failure time with shape =1/sigma


  Time_Shape = 1/base[2]#Generate failure time with (shape =1/sigma)
             ^
SyntaxError: invalid syntax

如果我删除导致错误的行,无效的 suntax 将移动到下一行:

s_0=[1,1]

它工作正常,突然开始提供无效语法。我不明白为什么!!

这里你漏掉了括号。

Time_Scale =(np.exp(base[0]+base[1]*0.25)) # <=== here

但是你应该这样写:

Time_Scale = np.exp(base[0]+base[1]*0.25)

不需要括号