当前位置:网站首页>list.replace, str.append
list.replace, str.append
2022-06-25 12:10:00 【燕策西】
问题描述
append 为何返回空值?replace 操作又为何频频失效?
# 1):
a = np.array([1., 2., 3.])
b = np.array([1., 2., 4.])
c = list(a)
d = c.append(b)
print(d)
# 2):
s = ' 0.00000000 -0.07024802'
s.replace(' ', '#')
print(s)
None
0.00000000 -0.07024802
原因及解决方法
list.append不返回任何值,不能用变量接收,而str.replace恰好相反,它返回一个原字符串的复制版本(copy),需要用新变量接收.
# 1):
a = np.array([1., 2., 3.])
b = np.array([1., 2., 4.])
c = list(a)
c.append(b)
print(c)
# 2):
s = ' 0.00000000 -0.07024802'
new = s.replace(' ', '#')
print(new)
[1.0, 2.0, 3.0, array([1., 2., 4.])]
##0.00000000###-0.07024802
完结撒花。
边栏推荐
- Today, I will explain to you what is DFI and its development prospects
- Matlab simulation of m-sequence
- Embedded software development written examination and interview notes (latest update: February 17, 2022)
- Renrenyue -- renrenyue system development source code sharing
- 三入职场!你可以从我身上学到这些(附毕业Vlog)
- Thinkphp3 reinforcement i() function filter single quotation marks
- Zhangxiaobai's road to penetration (7) -sql injection detailed operation steps -union joint query injection
- Zhangxiaobai's road of penetration (VI) -- the idea and process of SQL injection and the concat series functions and information of SQL_ Schema database explanation
- Flutter automatically disappears after receiving push
- Total number of MySQL statistics, used and unused
猜你喜欢
![按权重随机选择[前缀和+二分+随机target]](/img/84/7f930f55f8006a4bf6e23ef05676ac.png)
按权重随机选择[前缀和+二分+随机target]

(7) Pyqt5 tutorial -- > > window properties and basic controls (continuous update)

ECSHOP commodity page multi-attribute batch purchase plug-ins ECSHOP wholesale plug-ins multi-attribute order placing, multi-attribute batch purchase of commodities

Zhangxiaobai's way of penetration (V) -- detailed explanation of upload vulnerability and parsing vulnerability

Laravel excel export

Idea2017 how to set not to automatically open a project at startup

mysql FIND_ IN_ Set function

Go from 0 to 1. Obtain the installation package, get, post request, params, body and other parameters

K8s, docker compose install MySQL 8.0.18

2021-10-21
随机推荐
visual studio2019链接opencv
JS array de duplication
为何数据库也云原生了?
Error while sending STMT_ PREPARE packet. PID=29294
Laravel is not logged in and cannot access the background by entering the URL
Node child processes and threads
yolov5训练使用的负样本图片
VIM common commands and shortcut keys
JQ verifies whether the input color is legal
Idea2017 how to set not to automatically open a project at startup
Go defer little knowledge
架构师需要具备的能力
Figure explanation of fiborache sequence
聊聊高可用的 11 个关键技巧
冷启动的最优解决方案
The difference between this and super and their respective functions
Concat(), join(), reverse(), sort() method in JS array
ECSHOP commodity page multi-attribute batch purchase plug-ins ECSHOP wholesale plug-ins multi-attribute order placing, multi-attribute batch purchase of commodities
架构师必备的七种能力
Singleton mode in PHP to reduce memory consumption