标签:十六 mil print 实例 microsoft alt 方式 使用字符串 ima
# ASCII 码
a = ord("赵");
b = ord(‘文‘);
c = ord(‘卓‘);
print(‘赵的ASCII码对应‘,a,‘文的ASCII码对应‘,b, ‘卓的ASCII码对应‘,c);
c = chr(66);
print(c);
# 占位符	替换内容
# %d	整数
# %f	浮点数
# %s	字符串
# %x	十六进制整数
print(‘%2d - %02d‘ % (3, 1));
print(‘%.3f‘ % 3.1415926)
# 另一种格式化字符串的方法是使用字符串的format()方法,它会用传入的参数依次替换字符串内的占位符{0}、{1}……,不过这种方式写起来比%要麻烦得多:
print(‘Hello, {0}, 成绩提升了 {1:.2f},‘.format(‘小明‘, 17.125));
运行结果

标签:十六 mil print 实例 microsoft alt 方式 使用字符串 ima
原文地址:https://www.cnblogs.com/zhaoyiguang/p/14764559.html