Python:如何设置多个变量(名称长度不同)的声明样式
Python: How to style declarations of multiple variables (of different name lengths)
我正在寻找在 Python 中声明多个变量的最简洁的方法。我的代码如下所示:
app_type = config_data["app"]
app_params = config_data["app_data"]
original_fps = config_data["main"][0]["original_fps"]
sub_sampled_fps = config_data["main"][0]["sub_sampled_fps"]
max_retries = config_data["main"][0]["max_retries"]
win_size = config_data["main"][0]["window_size"]
input_frame_rate = config_data["main"][0]["input_frame_rate"]
样式指南可以接受这样的东西吗?
app_type = config_data["app"]
app_params = config_data["app_data"]
original_fps = config_data["main"][0]["original_fps"]
sub_sampled_fps = config_data["main"][0]["sub_sampled_fps"]
max_retries = config_data["main"][0]["max_retries"]
win_size = config_data["main"][0]["window_size"]
input_frame_rate = config_data["main"][0]["input_frame_rate"]
如果没有,有没有更好的方法来设计它?
根据pep8
不推荐:
# Correct:
x = 1
y = 2
long_variable = 3
# Wrong:
x = 1
y = 2
long_variable = 3
见参考资料here
我正在寻找在 Python 中声明多个变量的最简洁的方法。我的代码如下所示:
app_type = config_data["app"]
app_params = config_data["app_data"]
original_fps = config_data["main"][0]["original_fps"]
sub_sampled_fps = config_data["main"][0]["sub_sampled_fps"]
max_retries = config_data["main"][0]["max_retries"]
win_size = config_data["main"][0]["window_size"]
input_frame_rate = config_data["main"][0]["input_frame_rate"]
样式指南可以接受这样的东西吗?
app_type = config_data["app"]
app_params = config_data["app_data"]
original_fps = config_data["main"][0]["original_fps"]
sub_sampled_fps = config_data["main"][0]["sub_sampled_fps"]
max_retries = config_data["main"][0]["max_retries"]
win_size = config_data["main"][0]["window_size"]
input_frame_rate = config_data["main"][0]["input_frame_rate"]
如果没有,有没有更好的方法来设计它?
根据pep8
不推荐:
# Correct:
x = 1
y = 2
long_variable = 3
# Wrong:
x = 1
y = 2
long_variable = 3
见参考资料here