Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PyYAML read list of int
#1
I'm using a config.yaml and want to read a list of integers in "week":
{'worksheet_name': 'March 2024',
 'week': [12, 13],
 'name': 'John Doe',
 'username': 'jd9003'}
Reading this yaml with
with open("config.yaml", encoding='utf8') as f:
    cfg = yaml.load(f, Loader=yaml.FullLoader)
strangely leads to this value
week: [[12, 13]]
and not to
week: [12, 13]
Which format should be used for a list of int in yaml?
Reply


Messages In This Thread
PyYAML read list of int - by zisco - Mar-30-2024, 09:21 AM
RE: PyYAML read list of int - by snippsat - Mar-30-2024, 10:34 AM
RE: PyYAML read list of int - by zisco - Apr-02-2024, 12:36 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to read module/class from list of strings? popular_dog 1 532 Oct-04-2023, 03:08 PM
Last Post: deanhystad
  read a text file, find all integers, append to list oldtrafford 12 3,784 Aug-11-2022, 08:23 AM
Last Post: Pedroski55
  How to call/read function for all elements in my list in python johnny_sav1992 1 2,126 Jul-27-2020, 04:19 PM
Last Post: buran
  How to read a text file into a list or an array musouka 2 2,932 Oct-07-2019, 01:54 PM
Last Post: musouka
  Question about YAMLLoadWarning (PyYAML error / deprecated) UniKlixX 4 4,336 Sep-10-2019, 11:49 AM
Last Post: UniKlixX
  PyYAML millpond 2 2,990 Aug-01-2019, 03:19 AM
Last Post: millpond
  ThreadPoolExecutor read file to list DaLiPy 3 6,340 Jun-11-2019, 05:55 AM
Last Post: DaLiPy
  Read list of IP addresses from file and return a network dflick 4 4,975 Oct-27-2018, 09:33 AM
Last Post: buran

Forum Jump:

User Panel Messages

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