# Python 2 中的 print 语句示例
# 最简单的用法,直接输出字符串
print "Hello, World!"
# 输出多个值,使用空格分隔
print "The answer is", 42
# 输出变量
name = "Alice"
age = 30
print "Name:", name, "Age:", age
# 使用换行符
print "First line\nSecond line"
# 输出到文件(假设文件已打开并命名为 f)
f = open('output.txt', 'w')
print >>f, "This will be written to output.txt"
f.close()
print 在 Python 2 中是一个语句而不是函数。>>file_object 可以将输出重定向到文件。Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站