如图
我用的python2.7.代码如下
while 1:
input_num = input("please input a integer:")
if input_num <= 0:
print "input error!"
continue
total = 0.0
for i in range(1, input_num+1):
if i % 2:
total += 1/float(i)
else:
total -= 1/float(i)
print '{0:.2f}'.format(total)