`rm -rf *` (-x '/etc/passwd'); "interpolated $string"; # # "string with \n line breaks (etc)"; 'string with \n no $fancy tricks'; $foo =~ /\d+/; $foo =~ s/^\s+|\s+$//g; |
import commands
commands.getoutput("rm -rf *")
import os
os.path.exists('/etc/passwd')
"interpolated %s" % string
'interpolated %(string)s' % {'string': string}
'interpolated %s %s %s' % ($x, $y, $z)
"string with \n line breaks (etc)"
r"string with \n no $fancy tricks"
import re
re.search('\d+', foo) # or...
foo.isdigit()
foo = foo.strip() # or
re.sub(r'^\s+|\s+$', '', foo);
|
Python strings have methods to do some of the common things you'd use regexps for in perl.