python - 过滤字符串并仅获取整数
问题描述
我正在使用 PYTHON3 我的输出是这样的“200:就在手边”我只需要 200 有没有办法删除字符串和符号?谢谢
解决方案
>>> txt = "200:Just be close at Hand"
>>> txt.split(":")[0]
'200'
推荐阅读
- arrays - 使用 3 阵列检查能力
- android - react-native fb phone auth android signInWithPhoneNumber error [auth/app-not-authorized] ... [通过了一个安全网令牌
- c++ - 每当我输入不同的数据类型时,我都会进入无限循环
- python - 使用 asyncio 并行化工作的正确方法
- sql-server - SQL Server 在导入期间将美国日期格式转换为英国?
- loops - 如何使用 Ansible 将 IP 添加到从 10.xx66..10.xx83 迭代的 18 个虚拟机上的 Linux 主机文件
- api - Revenuecat REST API - 记录购买时获得的 Content-Type 不是 application/json
- bash - 在 BASH 中进行命令替换时,选择和陷阱 INT 会显示不同的行为
- security - 使用 esp-idf 在 esp32 上安全启动和闪存加密
- reactjs - 在 React 中 hotreload 究竟是如何工作的?