如何在路径的上下文中使用“〜"(波浪号)? [英] How do I use '~' (tilde) in the context of paths?

查看:93
本文介绍了如何在路径的上下文中使用“〜"(波浪号)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个Web应用程序开发新手.我有一个打开文件并读取它的功能.不幸的是,测试服务器和生产服务器之间的目录结构不同.有人告诉我使用相对于〜的路径".不过,我还找不到'〜'上的任何资源!

I'm a web application development noob. I have a function that opens a file and reads it. Unfortunately, the directory structures between the test and production servers differ. I was told to "use a path relative to ~". I haven't been able to find any resources on the '~', though!

如何在路径的上下文中使用波浪号?

How do I use the tilde character in the context of paths?

这是在Python中.我使用 os.path.expanduser(' 〜/path/in/home/area').

This is in Python. I fixed the problem, using os.path.expanduser('~/path/in/home/area').

推荐答案

它是您在UNIX中的$HOME变量,通常是/home/username.

it is your $HOME var in UNIX, which usually is /home/username.

您的家"是指正在执行cd ~/MyDocuments/之类的命令的用户的家是cd /home/user_executing_cd_commnd/MyDocuments

"Your home" meaning the home of the user who's executing a command like cd ~/MyDocuments/ is cd /home/user_executing_cd_commnd/MyDocuments

这篇关于如何在路径的上下文中使用“〜"(波浪号)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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