我如何使我的glob在Linux上适用于齿轮 [英] How can I make my glob work for cogs on Linux

查看:71
本文介绍了我如何使我的glob在Linux上适用于齿轮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Unix / Linux系统的新手,我在Windows计算机上对此程序进行了编程,因此它可以正常工作,并且我查看了并感到非常困惑。

I'm very new to Unix/Linux systems, I programmed this on my Windows machine so it works just fine, and I looked at this and got very confused.

这是我的全局代码:

COGS = [path.split("\\")[-1][:-3] for path in glob("./lib/cogs/*.py")]

在此,感谢您的回答,谢谢!

In advanced, I appreciate your answers, thank you!

推荐答案

我不确定您的输出格式是什么,但是我猜想您的 path.split( \ \)导致了您的问题,因为Windows使用 \ 。我可以通过将其简单地更改为 path.split( /)来获得自己的齿轮列表,因为linux使用 / 作为路径分隔符

I'm not sure what format your output is but I am guessing that your path.split("\\") is causing your issue, as Windows uses \. I get a list of my cogs by simply changing this to path.split("/"), as linux uses / as a path separator

或使用 os.sep

这篇关于我如何使我的glob在Linux上适用于齿轮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆