作者FoxTz (福斯梯Z)
看板Python
标题[问题] 关於print 上标 下标 字体
时间Wed Jul 25 15:39:01 2018
各位版友好
最近刚看书, 学到def
就写了一个输入半径
算出圆形面积
简单程式如下
def area(radius):
result = radius * radius * 3.14
return result
i = int(input('Please enter the radius (in CM): '))
print ('The area is %5.2f CM2: ' % area(i))
突然想到一个问题
我想要把print出的CM2 变成 CM2 (2上标)
搜寻了Google,好像没有看到有用的资讯
============================================
如
http://wiki.python.org.tw/%E8%AA%AA%E6%98%8E/%E6%8E%92%E7%89%88
范例中的
上标字与下标字
You might recall ''a''^2^ + ''b''^2^ = ''c''^2^ from your math lessons,
unless your head is filled with H,,2,,O.
结果:
You might recall a2 + b2 = c2 from your math lessons, unless your head is
filled with H2O.
我按照教学
x = ("You might recall ''a''^2^ + ''b''^2^ = ''c''^2^ from your math lessons,
unless your head is filled with H,,2,,O.")
print (x)
结果:
You might recall ''a''^2^ + ''b''^2^ = ''c''^2^ from your math lessons,
unless your head is filled with H,,2,,O.
没变啊!!!!
请问在不用import的方式,
可以把CM2 的2上标吗? 感谢
--
※ 编辑: FoxTz (36.228.236.116), 07/25/2018 15:39:28
1F:推 ckc1ark: print(u'a\u00b2+b\u00b2=c\u00b2') 07/25 15:48
2F:推 coeric: 推楼上,第一次学到py也可以这麽打.... 07/25 17:58
3F:→ Marsden: 意义不大。早期数学式的表示要嘛透过 HTML 要嘛就是用 ^ 07/25 19:23
4F:→ Marsden: 代表次方项。在 console 介面作这种事情根本没意义,关 07/25 19:24
5F:→ Marsden: 於这部份去找一份资料看一下文字编码的问题吧。 07/25 19:24
6F:推 iphone2003: console没有反法显示次方这种的吧。如果是要画图的时 07/26 08:56
7F:→ iphone2003: 候用,那我觉得用latex比较快 07/26 08:56
8F:→ iphone2003: *办法 07/26 08:56