所以我试图分析来自特定时区的推文情绪值。我正在尝试检查具有某些经度和纬度坐标的特定时区。如何在if语句中测试多个条件?或者在for循环中?我是否放括号或东西?
for line in infile:
line=line.rstrip()
words=line.split()
firststriplat=words[0].rstrip(",")
lat=firststriplat.lstrip("[")
lat=float(lat)
long=words[1].rstrip("]")
long=float(long)
easternlat=lat>=24.660845 and lat=<49.189787
easternlong=long>=-87.518395 and long=<-67.444574
if easternlat and easternlong:
在Python中,您可以执行以下操作来检查变量是否在特定范围内:
if (24.660845 <= lat <= 49.189787) and (-87.518395 <= long <= -67.444574):
pass
使用支架,你正在测试什么类型的条件?,即多少
例如,如果您有多个>和==,
你可以做点什么。
(Con A == con B)和(conC == conD)