我正在使用Python2.7和Ecplise工作区。
通过使用原始输入,这段源代码对我来说工作得很好import time
startTime = time.clock()
print "{0:*^80}".format(" Begins ")
name = raw_input('Please give the name : ')
print "Name is : ".ljust(40, '.'), name
print "Length of name : ".ljust(40, '.'), len(name)
radius = float(raw_input('Please enter the radius of circle : '))
print "Radius is : ".ljust(40, '.'),radius
diameter = float(2 * radius)
print "Diameter of circle is : ".ljust(40, '.'), diameter
print "\n{0:*^80}".format(" End ")
print "\nElapsed time : ", (time.clock() - startTime)*1000000, "microseconds"
这里,输入:
姓名:“先生!Guido von Rossum“和
半径:1.1
输出:************************************ Begins ************************************
Please give the name : Sir! Guido von Rossum
Name is : .............................. Sir! Guido von Rossum
Length of name : ....................... 21
Please enter the radius of circle : 1.1
Radius is : ............................ 1.1
Diameter of circle is : ................ 2.2
************************************* End **************************************
Elapsed time : 3593748.49903 microseconds
我想,也许它能帮助你或其他人。
谢谢