码迷,mamicode.com
首页 > 其他好文 > 详细

查看对象的类或对象所具备的功能:

时间:2017-09-01 10:47:14      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:查看   将不   win   nic   help   inpu   utf-8   str   输入   

 

1.
temp = "alex"
t = type(temp)
print (t)
#str , 按住ctrl +鼠标左键 找到str类
2.dir
temp = "alex"
b = dir(temp)
3.help,type
    help(type(temp))
4.直接点击
     temp = “alex”
     temp.upper()
     鼠标放在upper()上 ctrl +左键,自动定位upper 功能处

# -*- coding:utf-8 -*-
py2:
temp = "李杰" # utf-8
# 解码, 需要指定原来是什么编码
temp_unicode = temp.decode(‘utf-8‘)
# 编码, 需要指定要编成什么编码
temp_gbk = temp_unicode.encode("gbk")

print(temp_gbk)
py3:
py3 ,自动装换 utf-8 Unicode gbk
          移除了Python的Unicode类型
temp = "李杰"
temp_gbk = temp.encode(‘gbk‘)


对于Py27
     utf-8>gbk
     utf-8解码Unicode 编码gbk
py 3.5
     utf-8编码成gbk
windows 上输出
     utf-8 ->>unicode

写功能代码的规则:
raw_input :
用于和用户交互,等待用户输入内容

变量i1 代指某个   ”东西 ”
break 
用于跳出当前循环,并且break下面的代码将不再执行
continue
用于跳出本次循环,继续下一次循环

查看对象的类或对象所具备的功能:

标签:查看   将不   win   nic   help   inpu   utf-8   str   输入   

原文地址:http://www.cnblogs.com/wuguobiao/p/7461987.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!