Python中format的这种用法是什么含义?求解
def get_serial_number_str(device):
# 判断device类是否有'serial_number'属性
if hasattr(device, 'serial_number'):
return format(device.serial_number, 'x').upper()
else:
return "[unknown serial number]"
return format(device.serial_number, 'x').upper() 这一句