From 870723660942e9acf06d284b1da90df83348a36d Mon Sep 17 00:00:00 2001 From: cclauss Date: Fri, 28 Dec 2018 23:47:57 +0100 Subject: [PATCH] Use print() function in both Python 2 and Python 3 Legacy __print__ statements are syntax errors in Python 3 but __print()__ function works as expected in both Python 2 and Python 3. --- examples/TurtleStrategy/turtleEngine.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/TurtleStrategy/turtleEngine.py b/examples/TurtleStrategy/turtleEngine.py index 5c3b09e9..aa6603f6 100644 --- a/examples/TurtleStrategy/turtleEngine.py +++ b/examples/TurtleStrategy/turtleEngine.py @@ -1,5 +1,7 @@ # encoding: UTF-8 +from __future__ import print_function + from csv import DictReader from datetime import datetime from collections import OrderedDict, defaultdict @@ -306,7 +308,7 @@ class BacktestingEngine(object): #---------------------------------------------------------------------- def output(self, content): """输出信息""" - print content + print(content) #---------------------------------------------------------------------- def getTradeData(self, vtSymbol=''): @@ -432,4 +434,4 @@ class DailyResult(object): def formatNumber(n): """格式化数字到字符串""" rn = round(n, 2) # 保留两位小数 - return format(rn, ',') # 加上千分符 \ No newline at end of file + return format(rn, ',') # 加上千分符