LIST = ['Python','problem','whatever']

print(LIST)

When I run this program I get

[Python, problem, whatever]

Is it possible to remove that square brackets from output?

解决方案

You could convert it to a string instead of printing the list directly:

print(", ".join(LIST))

If the elements in the list aren't strings, you can convert them to string using either repr (if you want quotes around strings) or str (if you don't), like so:

LIST = [1, "foo", 3.5, { "hello": "bye" }]

print( ", ".join( repr(e) for e in LIST ) )

Which gives the output:

1, 'foo', 3.5, {'hello': 'bye'}

python去除列表的方括号,如何从Python列表中删除方括号?相关推荐

  1. python去除最后的逗号_Python如何从打印中删除最后一个逗号(string,end=“,”)...

    forloop的输出是string = "" for x in something: #some operation string = x += string print(stri ...

  2. php 去掉json外层 方括号,从 JSON 中删除方括号 - WITHOUT_ARRAY_WRAPPER 选项

    从 JSON 中删除方括号 - WITHOUT_ARRAY_WRAPPER 选项Remove Square Brackets from JSON - WITHOUT_ARRAY_WRAPPER Opt ...

  3. python清洗数据去除停用词_Python从pandas数据帧中删除停用词

    我想从我的专栏"tweets"中删除停用词.如何迭代每一行和每个项目? pos_tweets = [('I love this car', 'positive'), ('This ...

  4. python去除噪点_如何用python搞定验证码中的噪点

    背景:朋友在为"关山口男子职业技术学校"写一款校园应用,于是找MoonXue写一个学生选课系统的登录接口.为了搞定这个接口,不得不先搞定这个系统的验证码. 验证码大概是这个样子 看 ...

  5. python去除图片复杂背景_3行Python代码实现10秒抠图换背景图的AI神器,根本无需PS...

    人工智能课程大升级,限时优惠仅限前100名​sourl.cn 前言 对于会PhotoShop的人来说,抠图是非常简单的操作了,有时候几秒钟就能扣好一张图.不过一些比较复杂的图,有时候还是要画点时间的, ...

  6. python爆内存list_Python3基础 list del 从内存中删除整个列表

    ? ???????Python : 3.7.0 ?????????OS : Ubuntu 18.04.1 LTS ????????IDE : PyCharm 2018.2.4 ??????Conda ...

  7. python去除列表的方括号_Python正则表达式删除所有方括号及其内容

    我试图使用这个正则表达式从字符串中删除方括号(及其中的所有内容)的所有实例.例如,当字符串中只有一对方括号时,这种方法有效: import re pattern = r'\[[^()]*\]' s = ...

  8. Python去除列表中元素的前后空格和换行

    Python去除列表中元素的前后空格和换行 一行代码搞定: p = [x.strip() for x in square if x.strip() != ''] #square是列表

  9. python 从输出中删除列表方括号。

    如果想从输出中删除列表的方括号,可以将其转换为字符串,而不是直接打印列表: # 方法一: a_list=['monday','tuesday','wednesday','thursday','frid ...

最新文章

  1. 【错误记录】Android 应用运行报错 ( You need to use a Theme.AppCompat theme (or descendant) with this activity. )
  2. mysql binlog2sql_mysql闪回工具binlog2sql安装配置教程详解
  3. 网站发布错误“遭遇战”
  4. Excel 【小型成绩分析系统初稿】(功能及适应性有待完善)
  5. java sftp 公开键设定_如何使用JSch SFTP库解析Java UnknownHostKey?
  6. qt与JAVA服务器通信_Qt实现的SSL通信客户端和服务器
  7. pythonguitkinter编程入门_Python Tkinter GUI编程入门介绍
  8. 编译原理-FIRST表-FOLLOW表-LL1表(含python代码)
  9. 华为交换机防MAC地址漂移原理和实验
  10. WebView复制粘贴文本
  11. 计算机无法读光盘,win10系统无法读取光盘如何解决 win10系统读取光盘失败的解决方法...
  12. 哲学的终极解释:48张图了解48种主义
  13. 使用微信公众号给指定微信用户发送信息
  14. 面试考点:逻辑思维面试题(软件测试)
  15. Java调用外部api接口请求数据(阿里云ISBN查询图书信息为例)
  16. php phpmailer 发送邮件
  17. 水晶报表的制作(图表)
  18. 上海市大学生CTF(华东杯CTF) Crypto 全解
  19. Docker入门到部署
  20. linux运维前景2018,Linux运维工程师为什么越来越受企业重视?

热门文章

  1. 使用Shellter生成远控木马并进行持久化控制
  2. PIC单片机应用开发实践教程(七):PIC16F153xx——时钟使用
  3. 【AAAI 2022】OctAttention: Octree-based Large-scale Contexts Model for Point Cloud Compression
  4. 深度学习网络学习记录 SRI-Net、改进Unet
  5. iOS使用一些特殊键盘时的运行错误解决Can't find keyplane that supports type 4 for keyboard
  6. 二阶系统中阻尼系数和自然振荡频率的作用
  7. 《JavaScript权威指南》学习笔记(一)
  8. yongGC和FullGC多长时间执行一次比较好
  9. F28335中断系统详解及其应用
  10. 系统稳定性设计原则:简单、冗余、标准化、健壮