当前位置:网站首页>在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)

从上面的截图我们可以看出,提示没有了。
边栏推荐
猜你喜欢

Online text filter less than specified length tool

How to make the page number start from the specified page in word

Particle animation background login page particles js

在线文本过滤小于指定长度工具

Xiaojinwei, chairman of Chenglian Technology: implement the national strategy of data economy and lead the development of new consumption in the digital era!

Please use the NLTK Downloader to obtain the resource
![[pytoch] calculate the derivative of sin (x) by automatic differentiation](/img/a7/16dd9ecc13a986a9141ecc3fba00a1.png)
[pytoch] calculate the derivative of sin (x) by automatic differentiation

Sessions and Daemons

Cocos learning diary 2 - scripts and attributes
![Fundamentals of 3D mathematics [16] formulas for uniformly accelerated linear motion](/img/51/5b05694bbd0f4fd01dd26cf55b22c7.png)
Fundamentals of 3D mathematics [16] formulas for uniformly accelerated linear motion
随机推荐
Cool mouse following animation JS plug-ins 5
麦肯锡:2021年量子计算市场投资增长强劲,人才缺口扩大
[Shangshui Shuo series] day three - preview4
TS进阶之infer
【二叉樹進階】AVLTree - 平衡二叉搜索樹
Volatile and threads
[acnoi2022] no way without guessing
解决使用Exception抛出后,@Transactional不生效
一篇文章学会er图绘制
Ms-fsrvp forced abuse of POC
Fundamentals of 3D mathematics [16] formulas for uniformly accelerated linear motion
Monitoring artifact ZABBIX, from deployment to application, goes deep layer by layer
Online JSON to CSharp (c) class tool
Introduction and use of MySQL view
Pta:6-29 application of virtual base classes - people, teachers and students
There is a problem with redis startup
Pytoch --- pytoch customizes the dataset
论文阅读_关系抽取_CASREL
C语言刷题随记 —— 自由落体的球
【一起上水硕系列】Day Three - preview4