Created
July 31, 2023 12:25
-
-
Save TomoG29/c48a75b3717b632abaccbea242f74741 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import getpass | |
############################ | |
#入力・出力ファイルのパス指定 # | |
############################ | |
import_file_path = os.path.join('C:/Users',getpass.getuser(),'インポートしたいファイルパス') | |
export_file_path = os.path.join('C:/Users',getpass.getuser(),'エクスポートしたいファイルパス') | |
############################ | |
#ファイルを開く############### | |
############################ | |
import_file = open(import_file_path,"r",encoding='UTF-8') | |
export_file = open(export_file_path,'w',encoding='UTF-8') | |
############################ | |
#ファイルの内容を読み込む###### | |
############################ | |
data = import_file.read() | |
#実際の処理 | |
data += "\nsample" | |
############################ | |
#ファイルに書き込む########### | |
############################ | |
export_file.write(data) | |
############################ | |
#ファイルを閉じる############# | |
############################ | |
import_file.close() | |
export_file.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment