开发者

Python - Spaces in Filenames [duplicate]

开发者 https://www.devze.com 2022-12-21 07:05 出处:网络
This question already has answers here: Closed 12 years ago. Possible Dup开发者_StackOverflow中文版licate:
This question already has answers here: Closed 12 years ago.

Possible Dup开发者_StackOverflow中文版licate:

How to escape os.system() calls in Python?

Is there a Python method of making filenames safe (ie. putting \ infront of spaces and escaping ( , ), symbols) programatically in Python?


Spaces are already "safe" for Python in open(). As for os.system() and similar functions, use subprocess instead.


>>> import pipes
>>> pipes.quote("\&*!")
"'\\&*!'"
0

精彩评论

暂无评论...
验证码 换一张
取 消