我的Python脚本的目的是对所有作为参数提供的文件进行迭代,其用法如下:
usage: make_it_so.py [-h] filename [filename ...]
Make this and that
positional arguments:
filename
optional arguments:
-h, --help show this help message and exit
要运行它,我倾向于使用bash globbing,因为有多个文件。此外,我喜欢强调测试任何脚本,以确保它能够正确地处理包含空格的文件夹和文件,如下所示:
user@host:~$ ./make_it_so.py /path\ containing\ whitespaces/*.csv
或
user@host:~$ ./make_it_so.py '/path containing whitespaces/*.csv'
到目前为止,我主要是使用纯文本编辑器和终端进行编程。但是现在我想使用像PyCharm这样的IDE来更轻松地调试脚本。我的问题来了:
如何将调试配置配置为
(请参阅下面的调试配置示例。)
我在脚本中得到的参数列表与我所期望的不一样:
['/path', 'containing', 'whitespaces/*.csv', "'/path", 'containing', 'whitespaces/1st', "file.csv'", '/path\\', 'containing\\', 'whitespaces/2nd', 'file.csv']
相反,我希望:
['/path containing whitespaces/1st file.csv', '/path containing whitespaces/2nd file.csv']
我知道,PyCharm的调试配置中的参数输入字段不是bash。但我希望能以某种方式通过包含空格的论点。-有什么建议吗?
发布于 2022-08-07 12:26:21
您只需使用集成终端并手动执行make_it_so.py即可。
https://stackoverflow.com/questions/73267373
复制相似问题