new here and having issues! Course I'm taking is asking for me to convert a CSV string to JSON formatted string. I created inputs and created a CSV string:
def get_book_info():
title = str(input("enter book title: ").strip())
isbn = str(input("enter book ISBN: ").strip())
author = str(input("enter author last name: ").strip())
publisher = str(input("enter the book publisher: ").strip())
published = str(input("enter the year published: "))
price = "%.2f" % float(input("enter price: "))
price_book = str(price)
output = [title.title(),isbn,author.capitalize(),publisher.title(),published,price_book]
separator = "/"
info = separator.join(output)
return info
def to_csv_format(info):
title,isbn,author,publisher,published,price_book = info.split("/")
csv = f"{title},{isbn},{author},{publisher},{published},{price_book}"
print("The CSV Format String:")
print(csv)
return csv
Now, I need to help to create a JSON string using the CSV string. It's also asking me to use find(), string slicing and string concatenation for functionality. I see online help using import csv and import json but the problem is saying I can use find(), slicing and concatenation.
Thanks for your help!!
question from:
https://stackoverflow.com/questions/65863210/csv-formatted-string-and-returns-the-corresponding-json-format-string-python 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…