Just use the "+" format specifier:

$current.outTemp.format("%+.2f") will give something like

+22.12 for positive temperature
-22.12 for negative temperature



On Sun, Feb 21, 2021 at 9:35 AM D R <[email protected]> wrote:

> If the number is negative, it will print a "-" in front of the number.
>
> Despite looking through Python formatting pages from searches for Python
> Formatting, I cannot see that there is a provision to force a "+" in
> front of a number no matter what.
>
> For example:
>
> -23.7 is always given if negative,
>
> 45.2 is given but I'd like +45.2
>
> Is there a formatting character to do this?  I guess a long logical
> string to determine if the value is greater than zero, then toggle to
> print "+" if true, but that seems more than what I want to waste CPU
> cycles.  I was just hoping that some character had been assigned to
> force a +.
>
>
> Dale
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "weewx-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/weewx-user/77c84243-abb7-2e4e-19a1-876b6ecdce39%40gmail.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/CAPq0zEDnXJ_5Rzog8amwuVkU%3DP7ax%3Du-WsM0-ajxZLSSAm%3DE2w%40mail.gmail.com.

Reply via email to