我有一个这样的字符串:
my_string = '{"amountexvat":"0.14","amountincvat":"0.15","currency":"EUR","paymentmethods":[{"details":{"acquirerapprovalcode":"037464","acquirerid":"A0000000031010","acquirerpoiid":"gyytfft55","adyentransactionid":"1234","adyentransactiontimestamp":"2021-10-08T15:28:07.000Z","cardname":"kll","cardtype":"hhgh","entrymodes":["ICC"],"flourpaymentreference":"889999","merchantid":"888","paymentbrand":"test","paymentvariant":"visastandardcredit","poitransactionid":"12345","poitransactionreconciliationid":"1000","poitransactiontimestamp":"2021-10-08T17:28:07.000Z","terminalid":"866777","transactionamount":0.15,"transactioncurrency":"EUR"},"type":"ec"}],"products":[{"amount":1,"baseprice":"0.15","discount":"0","discountedprice":null,"itemvat":"0.01","pricepaidexvat":"0.14","pricepaidincvat":"0.15","unit":"piece","vendorchangedprice":true}],"salevat":"0.01"}'
我尝试将它上传到我的 fpdf 对象中,但在json 视图中。我试过这个:
import fpdf
# json view
x = json.loads(my_string)
# fpdf object
pdf = FPDF()
pdf.add_page()
pdf.set_font('Arial', 'B', 16)
pdf.cell(175, 10, 'TEST - report',0,1,'C')
pdf.multi_cell(0, 5, x)
但我得到的只是空白页作为输出。你知道如何处理它,或者问题出在哪里?
非常感谢。