当前位置:网站首页>Why should I use the source code of nametuple replace(‘,‘, ‘ ‘). Split() instead of split(‘,‘)
Why should I use the source code of nametuple replace(‘,‘, ‘ ‘). Split() instead of split(‘,‘)
2022-06-21 06:19:00 【Channing Lewis】

Recently in to see Python Of collections Bag nametuple Source code , See two lines of string manipulation :
if isinstance(field_names, str):
field_names = field_names.replace(',', ' ').split()
I'm curious , If you want to separate strings with commas , direct writing :
field_names = field_names.split(',')
Just fine .
Later, I realized that it was to be compatible with the situation of space segmentation . The source code can be written either by comma or by space , And it can be mixed ; But my writing only supports comma division .
边栏推荐
- R statistical plot - correlation of environmental factors +mantel test combination diagram (linket package introduction 1)
- Aurora8B10B IP使用 -02- IP功能設計技巧
- Sub-Category Optimization for Multi-View Multi-Pose Object Detection
- Aurora8B10B IP使用 -04- IP例程应用实例
- Leetcode刷题 ——— (4)字符串中的第一个唯一字符
- Aurora8b10b IP usage-02-ip function design skills
- Fastdfs cluster
- Aurora8b10b IP usage-05-transceiver test application example
- docker 安装mysql
- 【MYSQL】MySQL的SQL语句执行流程
猜你喜欢

FPGA - 7 Series FPGA selectio -03- ILOGIC of logic resources

contos7 安装svn服务端

Aurora8b10b IP usage-01-introduction and port description

You have an error in your SQL syntax; check the manual that corresponds to your MYSQL server

docker 安装mysql

数字信号处理-07-DDS IP应用实例

Docker installing MySQL

Copy the code generated by the code generator to the idea. How to solve the error reported by the web address after running

IP - 射频数据转换器 -04- API使用指南 - 系统设置相关函数

NumPy的广播机制
随机推荐
Backtracking method of graph coloring problem (the most easy to understand)
The database is 8.0 students. In this place, add this paragraph? useSSL=false&serverTimezone=GMT%2B8&characterEncoding=utf8
docker 安装mysql
计组必刷题:存储系统(已完结,附详细解析)
Required questions for group planning: storage system (completed, with detailed analysis attached)
牛客-TOP101-BM25
leetcode 410. Maximum value of split array - (Day30)
第一章:数据库系统概述(数据库期末复习)
Latest analysis on operation of refrigeration and air conditioning equipment in 2022 and examination question bank for operation of refrigeration and air conditioning equipment
Aurora8B10B IP使用 -01- 简介与端口描述
Improve the determination of the required items of business details. When the error information is echoed according to the returned status code, the echoed information is inconsistent with the expecta
Pycharm设置项目的默认解释器
tf. AUTO_ Reuse effect
第二章:数据模型(数据库期末复习)
微生物生态排序分析——CCA分析
Le premier caractère unique de la chaîne (4)
xshell7远程连接服务器,挂起进程一直维持程序的运行
Direct attack on the Internet layoffs in 2022: flowers on the ground, chicken feathers on the ground
After the code is generated by the code generator, the copy is completed, and the module is not displayed on the web page
[reproduce ms08-067 via MSF tool intranet]