[Python日记-1] 安装-字符串-数据类型-基本操作

Python零零散散学过很久了,这次想系统的扫一遍,仅以记录。

1. python2 | python3

1 print "Hello,world"    #python2
2 print ("Hello,world")    #python3

python3中的print成了一个函数,必须有()接收参数。

 

2. 字符串

 1 num = 123
 2 text = "   hello   "    
 3 
 4 print(text.title())    #text字符串首字母大写
 5 print(text.upper())  #大写
 6 print(text.lower())  #小写
 7 
 8 print(text.rstrip())  #清除text字符串右侧空格
 9 print(text.lstrip())  #清除左侧空格
10 print(text.strip())  #清除前后空格
11 
12 print(str(num)+"people")  #python3中的数字和字符串的拼接

简单介绍了关于字符串的大小写操作以及不同数据类型之间的str()拼接问题。

 

1 9**2    #乘方81

 

3. Python之禅

1 import this

 

照片暂空,没找到合适的图床。

希望明天学完这本书,开始做项目,三个项目还是很期待。

 

博客密码再次找回,迁移自新博客xinkwg - 实作于2020-2-6

posted @ 2020-02-07 15:43  viLogy  阅读(206)  评论(0编辑  收藏  举报