在Python中一般连接字符串与字符串,我们用+
操作符,但当+
操作符连接的是数字与字符串时则会报错,解决办法就是用str
将数字转为字符串,比如:
import sys
def outputNumbers(f, t):
output = ""
for i in range(f, t, 1):
output = output + str(i) + ";"
print output
outputNumbers(100,200)
Copyright© 2013-2020
All Rights Reserved 京ICP备2023019179号-8