![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
剑弑九幽L
在校学生
展开
-
python基础(一)
hello worldprint("hello python")支持中文#coding=utf-8 print("中文")变量python中的变量类型是运行时动态解析,所以不需要预先定义。 在python中,基本的变量类型有一下几种#coding=utf-8 a=47 b=12.02 #python中bool类型False和True开头字母需要大写 c=False d=True #字符串可以用单引原创 2016-11-03 21:34:25 · 228 阅读 · 0 评论 -
用*号搭建一个金字塔(python实现)
如图 * * * * * * * * * * * * * * * * * * * * * * * * * 代码如下#coding=utf-8 #raw代表要画的行数 raw=5 n=0 m=raw while n<(raw*2): #画空格 w=m while w>0: print " ",原创 2016-11-03 23:22:33 · 13155 阅读 · 2 评论 -
python 字符串常用操作
#coding=utf-8 str1=" dafhgfshhk lfhgj hhs dhfs " len(str1) #计算长度,当有中文时需要显示转换为utf-8编码,否则计算的结果会有误差 str2="中文" len(str2) #结果是 6 #将字符串显示转换为utf-8 str3=str2.decode("utf-8") len(str3) #结果为 2 str3=u"中文" #在字符串原创 2016-11-04 14:43:47 · 321 阅读 · 0 评论