一题多解(三)—— Python 字符串的拼接

1. format

def event_log(name, time):
    print('Event: {}, happens at {}'.format(name, str(time)))

2. 使用 + 连接符

def event_log(name, time):
    print('Event: ' + name + ', happens at ' + str(time))

3. 使用占位符

def event_log(name, time):
    print('Event: %s, happens at %s' % (name, str(time)))
原文地址:https://www.cnblogs.com/mtcnn/p/9424024.html