Skip to content

Instantly share code, notes, and snippets.

@668168
668168 / read_file_content.py
Created September 22, 2023 13:28
读取文件内容
def read_file_from_current_path(filename):
# 显示当前路径
current_path = os.getcwd()
print(f"当前路径是:{current_path}")
# 检查文件是否存在
file_path = os.path.join(current_path, filename) # 也可以直接使用文件名,如果文件在当前工作目录下
if os.path.exists(file_path):
print(f"{file_path} 存在。")
else:
@668168
668168 / read-csv.py
Created September 19, 2023 01:24
读取csv的标准方法
unique_names = []
with open(unique_names_file, 'r', encoding='utf-8') as f:
reader = csv.reader(f)
for row in reader:
if BUS_NUM != int(row[2]):
continue
unique_names.append(row)
print(unique_names)