2024-09-27 22:34:39 发布
网友
如何运行简单的python脚本并将其保存在文件中,但直接保存在linux命令行中:
fox@fox:/opt/gera# python -c print "aaaaa" > myfileName
但它只是不打印任何东西而不是“aaaaa”。你知道吗
python -c 'print "aaaaa"' > myfileName
在您的示例中,python运行python -c print,并给出“aaaaa”作为参数。你知道吗
python -c print
你必须引用整个命令:
否则,您将在Python中执行print(在Python 2中打印换行符,在Python 3中什么都不做,因为您只需计算函数print,而不调用它),并将aaaaa作为参数传递给脚本。你知道吗
print
aaaaa
你需要在代码周围加引号。你知道吗
在您的示例中,python运行
python -c print
,并给出“aaaaa”作为参数。你知道吗你必须引用整个命令:
否则,您将在Python中执行
print
(在Python 2中打印换行符,在Python 3中什么都不做,因为您只需计算函数print
,而不调用它),并将aaaaa
作为参数传递给脚本。你知道吗你需要在代码周围加引号。你知道吗
相关问题 更多 >
编程相关推荐