Python Forum
template string format specifiers
Thread Rating:
  • 2 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
template string format specifiers
#1
>>> f'{id:3s} : {location:19s} : {max_temp:3d} / {min_temp:3d} / {precipitation:5:2f}'.format(
id=id, location=location, max_temp=max_temp,
min_temp=min_temp, precipitation=precipitation
)
Traceback (most recent call last):
File "<pyshell#77>", line 1, in <module>
f'{id:3s} : {location:19s} : {max_temp:3d} / {min_temp:3d} / {precipitation:5:2f}'.format(
ValueError: Invalid format specifier

--Why am I getting this error? Please help. Thanks. All variables are assigned and match
Reply


Messages In This Thread
template string format specifiers - by VincentLamphier - Jan-13-2019, 01:27 AM
RE: template string format specifiers - by snippsat - Jan-13-2019, 07:47 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Set string in custom format korenron 4 1,048 Jan-16-2023, 07:46 PM
Last Post: mutantGOD
  Format String NewPi 2 908 Oct-10-2022, 05:50 PM
Last Post: NewPi
  TypeError: not enough arguments for format string MaartenRo 6 2,858 Jan-09-2022, 06:46 PM
Last Post: ibreeden
  string format challenge jfc 2 1,741 Oct-23-2021, 10:30 AM
Last Post: ibreeden
  Print first day of the week as string in date format MyerzzD 2 1,979 Sep-29-2021, 06:43 AM
Last Post: MyerzzD
  string.format() suddenly causing errors with google drive API zwitrader 0 1,733 Jun-28-2021, 11:38 PM
Last Post: zwitrader
  String to Date format SAF 2 2,412 Apr-06-2021, 02:09 PM
Last Post: snippsat
  MySQLdb._exceptions.ProgrammingError: not enough arguments for format string. farah97 0 3,297 Jan-22-2020, 03:49 AM
Last Post: farah97
  Highlight/Underline a string | ValueError: zero length field name in format searching1 1 2,987 Jul-01-2019, 03:06 AM
Last Post: metulburr
  write image into string format into text file venkat18 2 4,351 Jun-01-2019, 06:46 AM
Last Post: venkat18

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020