Python 使用多个打印函数后出现语法错误
Python syntax error after using multiple print functions
我刚刚开始自学 Python 我正在从事的项目。
这可能是一个相当菜鸟的问题,但是您可以使用打印功能的次数有限制吗?我的代码使用 Print 请求用户输入,但是在第 6 个实例中出现语法错误(无效语法)。据我所知,in/around 行没有错误。
我正在使用 Python 3.4.4.
问题所在行是;
print('What is the isentropic efficiency of the intake?')
代码的全部作用是;
# Define cycle
print('What is the cruise altitude (m)?')
altitude = float(input())
print('What is the cruise Mach number?')
print('What is the mass flow?')
W = float(input())
mach0 = float(input())
print('What is the OPR?')
OPR = float(input())
print('What is the TET?')
TET = float(input())
gamma = 1.4
Cp = 1000
# Calculate the freestream properties based on ISA
if altitude < 11000:
t0 = 288.15 - (6.5*(altitude/1000))
p0 = 101325*((1-(0.0065*(altitude/288.15)))**5.2561)
else:
t0 = 288.15 - (6.5*11)
p0 = (101325*((1-(0.0065*(11000/288.15)))**5.2561))*math.exp((-9.80665*(altitude-11000))/(287.04*t0))
# Calculate Intake Performance
T0 = t0*(1+(((gamma-1)/2)*(mach0**2)))
P0 = p0*((T0/t0)**(gamma/(gamma-1))
print('What is the isentropic efficiency of the intake?')
eta_intake = float(input())
T2 = T0*(1+(((gamma-1)/2)*eta_intake*(mach0**2)))
P2 = P0*((T2/T0)**(gamma/(gamma-1))
不,Python中的任何功能都可以使用多少次没有限制。该错误不是由带有 print
语句的行引起的。
上一行缺少右括号。应该是这样的:
P0 = p0*((T0/t0)**(gamma/(gamma-1)))
print('What is the isentropic efficiency of the intake?')
我刚刚开始自学 Python 我正在从事的项目。 这可能是一个相当菜鸟的问题,但是您可以使用打印功能的次数有限制吗?我的代码使用 Print 请求用户输入,但是在第 6 个实例中出现语法错误(无效语法)。据我所知,in/around 行没有错误。 我正在使用 Python 3.4.4.
问题所在行是;
print('What is the isentropic efficiency of the intake?')
代码的全部作用是;
# Define cycle
print('What is the cruise altitude (m)?')
altitude = float(input())
print('What is the cruise Mach number?')
print('What is the mass flow?')
W = float(input())
mach0 = float(input())
print('What is the OPR?')
OPR = float(input())
print('What is the TET?')
TET = float(input())
gamma = 1.4
Cp = 1000
# Calculate the freestream properties based on ISA
if altitude < 11000:
t0 = 288.15 - (6.5*(altitude/1000))
p0 = 101325*((1-(0.0065*(altitude/288.15)))**5.2561)
else:
t0 = 288.15 - (6.5*11)
p0 = (101325*((1-(0.0065*(11000/288.15)))**5.2561))*math.exp((-9.80665*(altitude-11000))/(287.04*t0))
# Calculate Intake Performance
T0 = t0*(1+(((gamma-1)/2)*(mach0**2)))
P0 = p0*((T0/t0)**(gamma/(gamma-1))
print('What is the isentropic efficiency of the intake?')
eta_intake = float(input())
T2 = T0*(1+(((gamma-1)/2)*eta_intake*(mach0**2)))
P2 = P0*((T2/T0)**(gamma/(gamma-1))
不,Python中的任何功能都可以使用多少次没有限制。该错误不是由带有 print
语句的行引起的。
上一行缺少右括号。应该是这样的:
P0 = p0*((T0/t0)**(gamma/(gamma-1)))
print('What is the isentropic efficiency of the intake?')