In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
What is the role of os.path.expanduser in python, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.
On linux, my account is kwsy, and the user's home directory is / home/kwsy. The following code shows how to use the expanduser function.
Python 3.7.0 (default, Jun 28 2018, 13:15:42)
[GCC 7.2.0]:: Anaconda, Inc. On linux
Type "help", "copyright", "credits" or "license" for more information.
> import os
> os.path.expanduser ('~ / .config /')
'/ home/kwsy/.config/'
In the directory ~ / .config/, ~ this is the representative of the user's home directory. If your account is sheng, then in shell, ~ / .config/ is equivalent to / home/sheng/.config,shell will help you find the absolute address of the directory, but in the python program, this equivalence relation is not true. Executing os.mkdir ('~ / test') will report an error, and python cannot recognize ~ / test as / home/sheng/test. You can use the expanduser function to replace ~ with the current user's hone working directory.
Under windows, my account name is zhangdongsheng and my working directory is C:\ Users\ zhangdongsheng
Python 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
> import os
> os.path.expanduser ('~ / .config /')
C:\\ Users\\ zhangdongsheng/.config/' will it be helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.