python3 print用法

"""
print用法
版本: v1.0
日期: 2019.03.25
作者: Catherine
python版本: 3.7
"""

print("用法1: ", end='')
print('hello, world!')
print()
print("用法2: ", end='')
print("你好,世界!")
print()
print("用法3: ", end='')
print('你好', '世界')
print()
print("用法4: ", end='')
print('hello', 'world', sep=', ', end='!')
print()
print()
print("用法5: ", end='')
print('goodbye, world', end='!\n')
print()
print("用法6: ")
s = 'Hello'
length = len(s)
print("The length of %s is %d" % (s, length))
print()
print("用法7: ")
pi = 3.141592653
print("字段宽10,精度3: ")
print('%10.3f' % pi)
print()
print("用*从后面的元组中读取字段宽度或精度: ")
print("pi = %.*f" % (3, pi))
print()
print("用0填充空白: ")
print('%010.3f' % pi)
print()
print("左对齐: ")
print('%-10.3f' % pi)
print()
print("显示正负号: ")
print('%+f' % pi)
    print()
print("用法8: ")
print("print不换行: ")
for i in range(10):
    print(i, end='')  # 0123456789
print()
print()
print("用法9: ")
list = ['床前明月光', '疑是地上霜', '举头望明月', '低头思故乡']  # 床前明月光-疑是地上霜-举头望明月-低头思故乡
print('-'.join(list))

你可能感兴趣的:(python,python3.7,print用法)