今天学习了字符串类型,类型的转换,注释及使用
字符串类型用引号标出,单引号、双引号只能同行,三引号可跨行注释(三引号为三次单引号或三次双引号)
类型的转换
不同类型直接链接发生typeerror(can only concatenate str not int to str
通过str()可将其他类型转为str类型(也可以用引号转换)
通过int()可将其他类型转换为int类型(文字类和小数类字符串无法转换,浮点数转化为整数,末尾取整)
通过float()可将其他类型转换为float类型(文字类无法转为整数,整数转为浮点数后面加.0)
注释及使用
#号后面为注释,运行时忽略,用于对代码进行注释,#为单行注释,三引号为多行注释
中文编码声明:
#coding:gbk可将保存编码由UTF-8改为ANSI
#coding:UTF-8可将编码改为UTF-8
12-07
3万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-29
4803
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-29
6140
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
01-18
1766
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-29
333
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交