2025-08-25 15:46:44 +08:00

27 lines
690 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 输出一个字符串
print("Hello, World!") # 输出Hello, World!
# 使用自定义分隔符
print("Hello", "World", sep=", ") # 输出Hello, World
# 自定义结束字符
print("Hello", end=" *** ") # 输出Hello ***
# 将输出写入文件
print("Hello", file=open("output.txt", "w")) # 文件内容Hello
"""
基础使用print输出你的名字。
"""
print("Henry Lin")
"""
应用使用print输出1到10的数字每个数字之间用逗号和空格分隔。
"""
print(1,2,3,4,5,6,7,8,9,10,sep=", ")
"""
挑战使用print将输出内容写入到一个名为output_2.txt的文件中。
"""
print("Save to output_2.txt", file=open("output_2.txt", "w"))