def to_representation(self, instance):
res = super().to_representation(instance)
res['receiver_phone_num'] = get_encryption_phone_num(instance.receiver_phone_num) if instance.receiver_phone_num else None
return res
第三行太长了,我正在努力从哪里中断并开始新的一行,使代码更加可读和清晰。
res['receiver_phone_num'] = get_encryption_phone_num(
instance.receiver_phone_num
) if instance.receiver_phone_num else None
res['receiver_phone_num'] = get_encryption_phone_num(instance.receiver_phone_num)\
if instance.receiver_phone_num else None
和
res['receiver_phone_num'] = get_encryption_phone_num(
instance.receiver_phone_num) if instance.receiver_phone_num else None
我更喜欢第一种断线的风格。你喜欢哪一种,或者你有没有其他线条分明、漂亮的款式,请给我看看。