您的位置:首页 > 编程语言 > Python开发

00初识python3

2015-08-29 01:28 549 查看
#直接输入abc,和用print(’abc')的区别
print('abc')
>>>abc    #直接输出结果
'abc'
>>>'abc'  #输出结果和类型

#路径处理
#1.直接将路径显示出来,此时路径结果并非我们想要的
>>> path = "c:\python33\1.txt"
>>> print(path)
c:\python33.txt
>>>
#2.使用原始字符串r,在路径前面加入r即可
>>> path =r"c:\python33\1.txt"
>>> print(path)
c:\python33\1.txt
>>>
#3.使用转义符\,将路径中的\进行转义
>>> path = "c:\\python33\\1.txt"
>>> print(path)
c:\python33\1.txt
>>>

#得到变量的数据类型
>>> type(1)
<class 'int'>
>>> type('a')
<class 'str'>
>>> type(1.23)
<class 'float'>
>>>
>>> isinstance(1,int)
True
>>> isinstance(1,float)
False
>>>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: