python ファイル読み込み·书き込み

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python ファイル読み込み·书き込み相关的知识,希望对你有一定的参考价值。

from datetime import datetime

filepath = 'hoge.csv'
with open(filepath, encoding='utf-8') as f:
  for row in f:
    columns = row.split(',')
    x1 = columns[0].strip()
    x2 = int(columns[1].strip())
    x3 = datetime.strptime(columns[3].strip(), '%Y-%m-%d %H:%M:%S')

with open('output/timecard.log', 'a', encoding='utf-8') as f:
    # 書き込み
    f.write(write_string)

以上是关于python ファイル読み込み·书き込み的主要内容,如果未能解决你的问题,请参考以下文章