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.
This commit is contained in:
cclauss 2018-12-28 23:47:57 +01:00 committed by GitHub
parent 9c79ab2167
commit 8707236609
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,7 @@
# encoding: UTF-8 # encoding: UTF-8
from __future__ import print_function
from csv import DictReader from csv import DictReader
from datetime import datetime from datetime import datetime
from collections import OrderedDict, defaultdict from collections import OrderedDict, defaultdict
@ -306,7 +308,7 @@ class BacktestingEngine(object):
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def output(self, content): def output(self, content):
"""输出信息""" """输出信息"""
print content print(content)
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def getTradeData(self, vtSymbol=''): def getTradeData(self, vtSymbol=''):
@ -432,4 +434,4 @@ class DailyResult(object):
def formatNumber(n): def formatNumber(n):
"""格式化数字到字符串""" """格式化数字到字符串"""
rn = round(n, 2) # 保留两位小数 rn = round(n, 2) # 保留两位小数
return format(rn, ',') # 加上千分符 return format(rn, ',') # 加上千分符