import datetime
a = 1
b = 2
c = 3
keta = 8
print(a)
print(‘answer = ‘ + str(a))
print(‘answer = {}’.format(a))
print(‘answer = {}{}’.format(a,b))
print(‘answer = {}{}{}’.format(a,b,c))
print(str(a) + ‘answer = {}{}{}’.format(a,b,c))
print(f’answer = {a}’)
print(f’answer = {a}{b}’)
print(f'{b}/{c}answer = {b/c:.5f}’)
print(f'{b}/{c}answer = {b/c:010.5f}’)
print(f'{b}/{c}answer = {b/c:0{keta}.5f}’)
ゼロ埋め
print(f’answer = {a:04}’)
print(f’answer = {a:0{keta}}’)
波括弧{}の扱い
print(f’answer = {{{a}}}’)
print(f'{{answer}} = {a}’)
now = datetime.datetime.now()
print(now)
print(‘結果一覧{0:%Y%m%d}{0:%H%M%S}.xlsx’.format(now))
print(‘{0:%Y%m%d}{0:%H%M%S}’.format(now))
|