This file contains hidden or 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
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: |
This file contains hidden or 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
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) |