使指数';立方';用Python?
如何在打印时使Python中的指数立方化 e、 g.使指数';立方';用Python?,python,Python,如何在打印时使Python中的指数立方化 e、 g.打印(“3***立方***”) 我不想把数字立方化——我想要符号 提前谢谢 我想制作这个体积计算器: 当它告诉你答案时,我希望它在最后打印成立方: height = input("Enter the height: ") if int(height) <0: print("Please enter a number larger than 0") height = input("Enter the height: ") i
打印(“3***立方***”)
我不想把数字立方化——我想要符号
提前谢谢
我想制作这个体积计算器:
当它告诉你答案时,我希望它在最后打印成立方:
height = input("Enter the height: ")
if int(height) <0:
print("Please enter a number larger than 0")
height = input("Enter the height: ")
if not int(height) < 2**31 - 1:
print("You have not entered a number")
height = input("Enter the height: ")
height = int(height)
width = input("Enter the width: ")
if int(height) <0:
print("Please enter a number larger than 0")
height = input("Enter the height: ")
if not int(height) < 2**31 - 1:
print("You have not entered a number")
height = input("Enter the height: ")
width = int(width)
length = input("Enter the length: ")
if int(length) <0:
print("Please enter a number larger than 0")
length = input("Enter the height: ")
if not int(length) < 2**31 - 1:
print("You have not entered a number")
length = input("Enter the length: ")
length = int(length)
volume = height*width*length
print ("The volume of the cuboid is" + str(volume) +"cm"
height=输入(“输入高度:”)
如果int(height)“使指数立方化”
没有意义。如果你想“立方体”一个数字,那意味着你想把它提升到三次方。换句话说,您希望指数为3
>>> 2**3
8
与2**31-1的内容可能重复?你知道整数在Python中可以任意变大吗?另外,如果用户输入了三次错误的高度怎么办?@Discoverer:butPy_ssize_t
是一个实现细节,在幕后使用,与int
完全不同。例如,尝试11**1000
,查看所有数字。Python整数仅受可用内存的限制。您正在查找unicode字符,³
。如果您的源代码支持unicode,您可以使用u'cm³'
获得它,否则您需要u'cm\u00b3'
(如果这是python 3,您不需要领先的u
s)当,我刚刚在写一个答案,现在它已暂停。。。要了解如何在Python中表示任何字符,只需从其他地方复制粘贴它(例如Word)并打印它的repr
:print repr(“³”)
产生'\xc2\xb3'
拼写错误:print(“长方体的体积是{}cm\u00b3”。format(volume))不打印(u“长方体的体积是{}cm\u00b3”。format(volume))@发现者什么?这是一个不同的答案吗?