python实现字符串和数字拼接
作者:weixin_42790526 时间:2023-05-29 07:05:29
如下所示:
将i前面加str(i)就可以了
补充拓展:python 连接字符串和数字
python 连接字符串和数字的问题:
首先要说的是,python是强类型的语言,如果你把一个字符串和数字直接做连接的操作的话,会报错:
TypeError: must be str, not int
下面是我们的一个例子:
a = 33
b = "33"c = a + b
如果你要数字和字符串连接的话,可以把数字通过str的方法转换成字符串的形式,然后再做连接的操作。
比如c = str(a) + b
最后的结果是:3333
来源:https://blog.csdn.net/weixin_42790526/article/details/83384463
标签:python,字符串,数字,拼接
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Django实现auth模块下的登录注册与注销功能
2022-03-06 17:49:15
![](https://img.aspxhome.com/file/2023/4/85124_0s.jpg)
Qt数据库应用之实现通用数据生成器
2024-01-16 00:37:49
![](https://img.aspxhome.com/file/2023/1/114931_0s.jpg)
Python爬取用户观影数据并分析用户与电影之间的隐藏信息!
2022-09-09 23:19:47
![](https://img.aspxhome.com/file/2023/9/103289_0s.png)
不通过数据源名DSN也能访问Access数据库吗?
2009-10-29 12:22:00
如何用Python破解wifi密码过程详解
2021-06-03 05:32:38
![](https://img.aspxhome.com/file/2023/6/72986_0s.gif)
Python实现基于权重的随机数2种方法
2022-10-13 03:25:40
100 个 Python 小例子(练习题一)
2022-09-25 20:45:52
解决MySQL主从数据库没有同步的两种方法
2024-01-15 03:34:44
基于Python实现一个简单的学生管理系统
2023-07-23 23:06:40
![](https://img.aspxhome.com/file/2023/7/82777_0s.jpg)
sql server创建复合主键的2种方法
2024-01-26 11:10:38
公网远程访问局域网SQL Server数据库
2024-01-22 01:38:21
![](https://img.aspxhome.com/file/2023/1/107691_0s.png)
利用python实现全屏爱心雨向喜欢的人表白
2022-05-29 22:32:14
![](https://img.aspxhome.com/file/2023/4/127644_0s.png)
Python3如何在服务器打印资产信息
2023-11-15 08:03:45
![](https://img.aspxhome.com/file/2023/5/63545_0s.png)
如何将Python脚本打包成exe应用程序介绍
2021-12-26 20:42:07
![](https://img.aspxhome.com/file/2023/4/81724_0s.png)
JavaScript如何获取一个元素的样式信息
2023-08-28 12:16:17
Protobuf在Cmake中的正确使用方法详解
2024-01-02 01:26:12
![](https://img.aspxhome.com/file/2023/1/123771_0s.png)
用私有属性来拯救IE7缩放图片的失真
2009-03-03 13:57:00
![](https://img.aspxhome.com/file/UploadPic/20093/3/feed-22s.gif)
SQL Server 使用 SET FMTONLY ON 获得表的元数据
2024-01-24 00:20:41
![](https://img.aspxhome.com/file/2023/3/106273_0s.jpg)
Tensorflow使用支持向量机拟合线性回归
2021-01-20 03:38:42
![](https://img.aspxhome.com/file/2023/7/92517_0s.jpg)
微信 java 实现js-sdk 图片上传下载完整流程
2024-04-29 14:08:03