pyhton文件读取:
导入需要用到的package
import os
import pandas as pd
定义文件路径
python在linux系统上进去文件I/O操作时,可以有多种方式定义文件路径,这里给出两种:
路径的一般范式: /home/login_user_account/directory_a/…/directory_n/filename.*****
/主目录/登录账号名/文件夹a/…/文件夹n/文件名及其格式
-
方式一:
path = '/home/test/test' file_name = os.path.join(path, 'testfile.txt') file_name