print的几种方法 2021-11-29 python 原创 0 评论 字数统计: 126(字) 阅读时长: 1(分) 1. 输出参数 123456789101112a = 2b = "hello"print("output: ", a, b) # 1print("output: %d %s" % (a, b)) # 2print("output: {} {}".format(a, b)) # 3print(f"output: {a} {b}") # 4'''output: 2 hellooutput: 2 hellooutput: 2 hellooutput: 2 hello''' 2. flush=True print(xxx, flush=True) print的输出是有条件的,在某些特定场合print语句结束之后是不会打印输出的,flush为True就是不论满不满足条件,只要print语句结束就可以立即输出