我的第一个问题,请温柔一点.我搜索但在这里或其他地方找不到答案.
My first question, please be gentle. I searched but could not find an answer here or elsewhere.
请注意,此问题不适用于 *args 等参数的解包.
Note that this question does not apply to unpacking of arguments like *args.
在 os.removexattr 声明如下:
os.removexattr(path, attribute, *, follow_symlinks=True)
Removes the extended filesystem attribute attribute from path.
attribute should be bytes or str. If it is a string, it is encoded
with the filesystem encoding.
This function can support specifying a file descriptor and not
following symlinks.
注意第三个参数是星号:*
Note that the third argument is a star: *
我假设这意味着指定一个属性或多个属性,用逗号分隔",但是当我尝试这样做时,我得到了一个例外:
I assumed that this means "specify one attribute or several attributes separated by comma", but when trying to do that, I get an exception:
import os
os.removexattr('M7-AAE-01.jpg', 'user.camera_brand', 'user.camera_model')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: Function takes at most 2 positional arguments (3 given)
我也尝试提供参数列表,但这也不起作用.
I also tried to supply a list of arguments, but that did not work either.
在这种情况下,星号参数究竟是什么意思?谢谢.
What exactly does the star argument mean in this case? Thank you.
单个星号 * 仅表示它强制您使用命名参数.在这种情况下,如果你想为 follow_symlinks 传递一个值,你必须传递参数名称.
The single asterisk * just means that it is forcing you to use named arguments. In this case if you want to pass a value for follow_symlinks, you have to pass the argument name.
这个想法是您不必阅读像 foo(True, False, False) 这样的函数调用并且不知道这些值在做什么.
The idea is you don't having to read function calls like foo(True, False, False) and not know what those values are doing.
这篇关于os.removexattr 的 Python 文档——'*'(星号)参数是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何在 Python 中将货币字符串转换为浮点数?How do I convert a currency string to a floating point number in Python?(如何在 Python 中将货币字符串转换为浮点数?)
在 Pandas 中解析多索引 Excel 文件Parsing a Multi-Index Excel File in Pandas(在 Pandas 中解析多索引 Excel 文件)
pandas 时间序列 between_datetime 函数?pandas timeseries between_datetime function?( pandas 时间序列 between_datetime 函数?)
pandas 重新采样到每月的特定工作日pandas resample to specific weekday in month( pandas 重新采样到每月的特定工作日)
Python - 如何标准化时间序列数据Python - how to normalize time-series data(Python - 如何标准化时间序列数据)
statsmodels 使用 ARMA 模型进行预测statsmodels forecasting using ARMA model(statsmodels 使用 ARMA 模型进行预测)