我有如下代码片段:
server_directory = "/Users/storm/server"
def get_directory(self, username):
home = server_directory + "/" + username
typic = os.getcwd()
if typic == server_directory:
return "/"
elif typic == home:
return "~"
else:
return typic
每次我从两个不错的服务器目录和用户的主目录中更改目录时,它看起来像/Users/storm/server/svr_user
. 由于我想模拟主目录和虚拟“根”目录,我该如何制作它/svr_user2
而不是?/Users/storm/server/svr_user