如何在Python中使用%格式化程序将大量格式格式化为2.1E8或3.2E10?
答案 0 :(得分:2)
使用这样的电子格式类型:
'%.1E' % 2182869
答案 1 :(得分:0)
%e
格式可用于此目的:
myint = 2334566778899
>>> print("%1.2e"%myint)
2.33e+12
答案 2 :(得分:0)
if user.present?
if user.basic?
can :read, :all
can :active_orders_index, Order
can :search_orders, Order
can :focused_show, Location
cannot :mark_task_completed, Task
can :finish_task, Task
cannot :manage, User # ADDED LINE
elsif user.location?
can :read, Location, :name => user.username
can :focused_show, Location, :name => user.username
cannot :manage, User
elsif user.admin?
can :manage, :all
cannot :manage, User, role: 3 # ADDED LINE
elsif user.moderator?
can :manage, :all
end
end