当前位置:网站首页>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 .
边栏推荐
- FPGA - 7系列 FPGA SelectIO -01- 简介与DCI技术简介
- Deeply understand the gradient disappearance of RNN and why LSTM can solve the gradient disappearance
- FPGA - 7系列 FPGA SelectIO -03- 逻辑资源之ILOGIC
- 当今的数学是否过于繁琐?
- 827. 最大人工岛 并查集
- Microbial ecological sequencing analysis -- CCA analysis
- 【数据挖掘】期末复习 第五章
- FPGA - 7 Series FPGA selectio -03- ILOGIC of logic resources
- FPGA - 7 Series FPGA selectio -05- logic of logic resources
- 对网页 ‘’为所欲为‘’ 之手动实现 csdn深色模式?
猜你喜欢

深度理解RNN的梯度消失和LSTM为什么能解决梯度消失

Broadcast mechanism of numpy

Solve the first problem of Huawei's machine test on April 20 by recursion and circulation (100 points)

【数据挖掘】期末复习 第二章

Aurora8b10b IP usage-01-introduction and port description

docker 安装mysql

FPGA - 7 Series FPGA selectio -05- logic of logic resources

Asp. Net web API 2 Lesson 18 - working with entity relations in OData
![[data mining] final review Chapter 5](/img/d1/0c16b881b018c2e29f028c2b937e17.png)
[data mining] final review Chapter 5

Improved Object Categorization and Detection Using Comparative Object Similarity
随机推荐
[is the network you are familiar with really safe?] Wanziwen
Microbial ecological sequencing analysis -- CCA analysis
Aurora8B10B IP使用 -03- IP配置应用指南
scala中函数和方法
Leetcode刷题 ——— (4)字符串中的第一个唯一字符
图着色问题回溯法(最通俗易懂)
回答问题:你认为AGI应该采用什么思路?
Do you want to manually implement CSDN dark mode for web page '?
tf. compat. v1.global_ variables_ initializer
Aurora8b10b IP usage-01-introduction and port description
[JVM] method area
User defined thread pool
leetcode 675. Cutting down trees for golf competitions - (day29)
Does intelligence need a body
Leetcode question brushing - (4) the first unique character in the string
tf. compat. v1.pad
上手自定义线程池
正则表达式基础
TypeError: iter() returned non-iterator of type ‘xxx‘
深度学习的几种优化方法