如何使用ofxparse更改ofx文件中的FITID?

2024-10-06 20:31:33 发布

您现在位置:Python中文网/ 问答频道 /正文

当我调试代码时,会发生更改,但是当我打开文件时,什么都没有更改。你知道吗

代码

from ofxparse import OfxParser
from datetime import datetime as dt

# opening ofx file
with open('/home/jovani/Downloads/ofx.ofx') as file:
    # Parser
    ofx = OfxParser.parse(file)
    #finding transactions
    transactions = ofx.account.statement.transactions
    now = dt.now() # I'll use this id like
    for fitid in transactions: #performing changes and it happens
        fitid_before = fitid.id
        fitid_after = now.strftime("%Y%m%d%f")
        fitid = fitid_after

后来,一切都没有改变ofx.ofx的文件。你知道吗


Tags: 文件代码fromimportiddatetimeasdt
1条回答
网友
1楼 · 发布于 2024-10-06 20:31:33

你在问为什么文件没有更改。你知道吗

  1. 您以只读方式打开了文件。这是“with open”的默认值。你知道吗
  2. 您没有尝试向文件写入任何内容。你知道吗

相关问题 更多 >