[英]This Python code to get the current file path will work on Linux?
Sorry if it's a stupid question, I don't know anything about Linux and I've had problems with paths in Linux, will this Python code I made in Windows work in Linux? Sorry if it's a stupid question, I don't know anything about Linux and I've had problems with paths in Linux, will this Python code I made in Windows work in Linux?
Code:代码:
File_Path = str(Path(__file__).parent.absolute())
User_Dir = File_Path + '/data'
If you can explain more about the compatibility of Python codes from Windows to Linux I would appreciate it.如果您能详细解释 Python 代码从 Windows 到 Linux 的兼容性,我将不胜感激。
For me, it will work, but I have 2 questions:对我来说,它会起作用,但我有两个问题:
File_Path = Path(__file__).parent.absolute() User_Dir = File_Path.join('data')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.