python - Python - 从列表中删除引号
问题描述
我有一个带有数字列表的数据框。打印列表时,我要删除前面和末尾的引号。我无法用替换功能替换它们。
a = df.iloc[0]['ids']
b = [a]
b (Output)
['2769734487041924, 7608779650164612'] <-- one quotation mark at beginning and end
我想要的(手动创建):
row_ids = [1234, 4567]
row_ids (Output)
[1234, 4567] <-- That's the format I want to get the list to, without the quotation marks
b和row_ids数据类型都返回为“列表”,因此必须有一种方法可以使列表不带引号。
解决方案
我认为a
是一个字符串,因此可以从中获取所需b
的整数列表
b = list(map(int, a.split(",")))
推荐阅读
- java - 我正在尝试运行一个 spring bot 应用程序,它显示执行 DDL 的 CommandAcceptanceException 错误
- javascript - react native : infinite loop with useEffect
- python - HTTPS proxies does not work when sending requests
- aws-cdk - ECS cdk blue green deployment
- linux - Ansible - 使用 systemd(.service 文件)运行剧本
- docker - Docker Desktop - Set "Open in Browser" default page
- windows - 在 Chrome 中调试无头环境
- python-3.x - 我的 alsaaudio / pygame 音乐播放器在以普通用户身份运行但不能以 root 用户身份运行时工作
- python - 抓取网页的所有 URL
- python - pip "文件语法、目录名或卷标错误"