これには ftputil モジュールを使用しましたが、ファイルへの 'a'(追加) の追加をサポートしていないという問題に遭遇し、'w' 経由で書き込むと内容が上書きされます。
それが私が試したことであり、私はそこで立ち往生しています:
with ftputil.FTPHost(host, ftp_user, ftp_pass) as ftp_host:
with ftp_host.open("my_path_to_file_on_the_server", "a") as fobj:
cupone_wr = input('Enter coupons with a space: ')
cupone_wr = cupone_wr.split(' ')
for x in range(0, len(cupone_wr)):
cupone_str = '<p>Your coupon %s</p>\n' % cupone_wr[x]
data = fobj.write(cupone_str)
print(data)
目標は、ファイルに古いエントリを残し、スクリプトが再度呼び出されるたびにファイルの最後に新しいエントリを追加することです。