If it were just 目录名,两遍直接加斜线,对于unix系统来说,并不会改变打开效果。 理论上windows类似,使劲加/,系统也会自动简化成一个。对,我说的是c:/Users/aa, not a backslash...
for i in os.walk("/tmp/a")
print i
for i in os.walk("/tmp/a/")
print i
for i in os.walk("//tmp/a")
print i
for i in os.walk("//tmp///a//")
print i
However, we should pay attention to two problems here. Both of these problems belong to improper use of changing the original path:
If it is originally a relative path, then after adding /之后会变成绝对路径,有可能会改变你本来想打开的路径。 如果原来是文件,那么后面加了/ in front, it will become a path, and an error will occur when opening.
About default permissions:
It is recommended to throw the following functions into ~/.bashrc
toucha(){
touch
chmod +x
}
This way the shell can use the toucha command directly
General programming languages will have a trim function, which can delete specified characters on both sides of a string. Generally, there are also ltrim and rtrim, which are used to only delete specified characters on the left or right side. Although python is not named after trim, you search for "python trim" Still using keywords, you can still find the answer you want. Good luck
If it were just
目录
名,两遍直接加斜线,对于unix系统来说,并不会改变打开效果。理论上windows类似,使劲加
/
,系统也会自动简化成一个。对,我说的是c:/Users/aa
, not a backslash...However, we should pay attention to two problems here. Both of these problems belong to improper use of changing the original path:
If it is originally a relative path, then after adding
/
之后会变成绝对路径,有可能会改变你本来想打开的路径。如果原来是文件,那么后面加了
/
in front, it will become a path, and an error will occur when opening.About default permissions:
It is recommended to throw the following functions into ~/.bashrc
This way the shell can use the toucha command directly
General programming languages will have a trim function, which can delete specified characters on both sides of a string. Generally, there are also ltrim and rtrim, which are used to only delete specified characters on the left or right side. Although python is not named after trim, you search for "python trim" Still using keywords, you can still find the answer you want. Good luck
One of the methods