当前位置:网站首页>在Pycharm中使用append()方法对列表添加元素时提示“This list creation could be rewritten as a list literal“的解决方法
在Pycharm中使用append()方法对列表添加元素时提示“This list creation could be rewritten as a list literal“的解决方法
2022-06-23 03:50:00 【昊虹图像算法】
在Pycharm中使用append()方法对列表添加元素时提示"This list creation could be rewritten as a list literal",截图如下:
"This list creation could be rewritten as a list literal。”它的意思为这个列表的创建可以重写得更简单。
什么意思?
我们看上面两行代码:
list1 = ['Google', 'CSDN', 'tencent', 1997, 1999, 1998]
list1.append(2000)
可以看到,因为中间没有任何操作,所以Pycharm判断两句代码完全可以合并成下面这条语句:
list1 = ['Google', 'CSDN', 'tencent', 1997, 1999, 1998, 2000]
所以它作了标题中的提示“This list creation could be rewritten as a list literal”。
怎么样让它消失呢?很简单,两句代码之间加入任意语句,比如下面这样:
list1 = ['Google', 'CSDN', 'tencent', 1997, 1999, 1998]
kkk = 1
list1.append(2000)

从上面的截图我们可以看出,提示没有了。
边栏推荐
- Pta:7-67 friend is very simple 2016final
- X24cxx series EEPROM chip C language universal reading and writing program
- [pytoch] calculate the derivative of sin (x) by automatic differentiation
- 国家药品不良反应监测中心 ADR 电子传输EDI解决方案
- [ACNOI2022]不猜不行
- How node+express operates cookies
- Pta:7-85 data spacing (overload + function template)
- Pta:6-33 student ranking table (destructor)
- Pytoch --- use pytoch's pre training model to realize four weather classification problems
- PTA:7-86 集合的模拟实现(函数模板)
猜你喜欢

flutter系列之:flutter中的Wrap

win10下安装、运行MongoDB

Svg+js smart home monitoring grid layout

Volatile and threads

It supports running in kubernetes, adds multiple connectors, and seatunnel version 2.1.2 is officially released!

Halcon知识:binocular_disparity 知识

x24Cxx系列EEPROM芯片C语言通用读写程序

C语言刷题随记 —— 自由落体的球

国家药品不良反应监测中心 ADR 电子传输EDI解决方案

语料库数据处理个案实例(词性赋码、词性还原)
随机推荐
Introduction to deep learning
LabVIEW在同一表中同时显示十六进制字符和普通字符
395. 冗余路径
Background ribbon animation plug-in ribbon js
Particle animation background login page particles js
什么是元数据
关于php里tcp通讯用swoole框架出现的小问题
Leetcode 1208. 尽可能使字符串相等(终于解决,晚安)
国家药品不良反应监测中心 ADR 电子传输EDI解决方案
Cool mouse following animation JS plug-ins 5
大一学生课设c——服装管理系统
2022金属非金属矿山(露天矿山)安全管理人员考试题模拟考试题库及答案
The spring recruitment in 2022 begins, and a collection of interview questions will help you
距离度量 —— 余弦距离(Cosine Distance)
[advanced binary tree] AVLTree - balanced binary search tree
Avltree - arbre de recherche binaire équilibré
golang使用mongo-driver操作——增(基础)
Chrome调试技巧
在线JSON转CSharp(C#)Class工具
Implementation of VGA protocol based on FPGA