当前位置:网站首页>TypeError: 'str' object does not support item assignment
TypeError: 'str' object does not support item assignment
2022-07-24 13:59:00 【Blue field soldier】
The following code is used to change the character at a certain position of the string , That's the problem
s = '312141'
s[0] = '0'
python String in with C++ It's a little different ,python The string of is a Immutable object (immutabel object), It means read-only and not write , Thread safety .C++ We can directly use the string of s[0]='0’ This syntax assigns a value to a character in a string , and python Can not be .
stay python in , You can first convert the string into a list , Then assign the value , Then turn it back . Reference resources stackoverflow One of the answers
s = '312141'
t = list(s)
t[0] = '0'
s = ''.join(t)
边栏推荐
- RHCE first operation
- Apache2 ha experiment with raspberry pie
- The R language uses the DOTPLOT function of epidisplay package to visualize the frequency of data points in different intervals in the form of point graphs, uses the by parameter to specify the groupi
- Nessus security testing tool tutorial
- Network security - filtering bypass injection
- 2021-07-09
- Difference between code signing certificate and SSL certificate
- 软链接、硬链接
- One problem encountered:
- 数据修改修改
猜你喜欢

Nmap security testing tool tutorial

JS execution mechanism

5年接触近百位老板,身为猎头的我,发现升职的秘密不过4个字

Apache2 ha experiment with raspberry pie

网络安全——使用Evil Maid物理访问安全漏洞进行渗透

2022.7.22 simulation match

How to quickly wrap lines in Excel table
![[untitled] rhcsa first operation](/img/ba/6b9c11edbc18ffb52f6046360b5b10.png)
[untitled] rhcsa first operation
![[C language note sharing] - dynamic memory management malloc, free, calloc, realloc, flexible array](/img/3f/35c9ff3be5c0ef781ffcb537287a20.png)
[C language note sharing] - dynamic memory management malloc, free, calloc, realloc, flexible array

Source code analysis of ArrayList
随机推荐
三层交换机配置MSTP协议详解【华为eNSP实验】
Stack and queue - 225. Implement stack with queue
栈与队列——232. 用栈实现队列
Network security - use exchange SSRF vulnerabilities in combination with NTLM trunking for penetration testing
RHCE first operation
Browser type judgment
Apache2 ha experiment with raspberry pie
Noip2021 T2 series
数据修改修改
rhcsa第六次笔记
【无标题】rhcsa第一次作业
FlinkTable&SQL(六)
Network security - file upload whitelist bypass
Cocoapod installation problems
Summary of week 22-07-23
Build ZABBIX monitoring service in LNMP architecture
Network security - war backdoor deployment
Data modification modification
Concurrent programming ----------- set
2022.7.22 simulation match