(这是一个查看应用程序源代码的python源代码)现我已开源
import os
def view_source_code(file_path): try: with open(file_path, 'r') as file: source_code = file.read() print(source_code) except FileNotFoundError: print("文件不存在!")
def main(): print("欢迎使用源代码查看器!") file_path = input("请输入要查看的文件路径:") if os.path.isfile(file_path): view_source_code(file_path) else: print("无效的文件路径!")
if __name__ == '__main__': main()