ValueError: cannot switch from manual field specification to automatic field numbering

前端 未结 3 2018
盖世英雄少女心
盖世英雄少女心 2020-12-14 14:54

The class:

class Book(object):
    def __init__(self, title, author):
        self.title = title
        self.author = author

    def get_entry(self):
              


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-14 15:19

    print ("{0:.1f} and the other no {0:.2f}".format(a,b)) 
    

    python cannot do both manual and automatic precision handling (field numbering) in a single execution of code. You can either go for specifying the field numbering for each variable or let python do it automatically for all.

提交回复
热议问题