我的工作在Django的web應用程序,但我得到的Python版本2.6.6的錯誤,但它是在2.7的Python - 2.6
def check(attribute):
global rates
if (attribute.temperature_value < rates[0] or
attribute.temperature_value > rates[1] or
attribute.heartbeat_value<rates[2] or
attribute.heartbeat_value>rates[3]):
return True
else:
return False
工作罰款2.7,但工作的錯誤Django調試器顯示有語法錯誤。
另外,如果我嘗試刪除功能我得到另一個錯誤在另一條線路上說
EOL while scanning string literal (views.py, line 109)
上線109:
data = \
DataPool(
series=
[{'options': {
'source': values},
'terms': [
'current_time',
'temperature_value',
'heartbeat_value']}
])
感謝您的幫助。
回溯:
File "/home/innovo/.local/lib/python2.6/site-packages/django/core/handlers/base.py" in get_response
101. request.path_info)
File "/home/innovo/.local/lib/python2.6/site-packages/django/core/urlresolvers.py" in resolve
300. sub_match = pattern.resolve(new_path)
File "/home/innovo/.local/lib/python2.6/site-packages/django/core/urlresolvers.py" in resolve
209. return ResolverMatch(self.callback, args, kwargs, self.name)
File "/home/innovo/.local/lib/python2.6/site-packages/django/core/urlresolvers.py" in callback
216. self._callback = get_callable(self._callback_str)
File "/home/innovo/.local/lib/python2.6/site-packages/django/utils/functional.py" in wrapper
27. result = func(*args)
File "/home/innovo/.local/lib/python2.6/site-packages/django/core/urlresolvers.py" in get_callable
92. lookup_view = getattr(import_module(mod_name), func_name)
File "/home/innovo/.local/lib/python2.6/site-packages/django/utils/importlib.py" in import_module
35. __import__(name)
Exception Type: SyntaxError at/
Exception Value: EOL while scanning string literal (views.py, line 114)
,你能否告訴既充分回溯的? –
作爲一個說明,看到一個在全局變量上工作的函數是一個不好的跡象 - 而不是將參考作爲參數傳遞給參數。你也可以簡化'if x:return true; else:返回False'到'return x'。 –
就我所知,字符串文字在2.6和2.7之間的工作方式應該沒有什麼區別,所以我對問題描述有點懷疑。 –