Skip to main content
 首页 » 编程设计

python之Perl 的反引号在 Python 中的等价物是什么

2025年05月04日13insus

<分区>

Possible Duplicate:
Equivalent of Backticks in Python

当我想在 Perl 中直接写入命令提示符时,我可以这样做:

Perl 文件test.pl:

$directory = `dir`;   
print $directory; 

这会输出类似..

C:\Documents and Settings\joslim\Desktop>perl test.pl

Volume in drive C has no label. Volume Serial Number is EC37-EB31

Directory of C:\Documents and Settings\joslim\Desktop
(and a listing of all the files..)

我可以在 Python 中执行此操作吗?我四处搜寻但没有运气。

还有,你能告诉我这个叫什么吗?我敢肯定还有比“直接写入命令提示符”更专业的术语......