#print输出 print(520) print('hello world') #输出运算符的表达式 print(3+2) #将数据输出到文件中 (将值负给fp) fp=open('D:/text.txt','a+')#这里的储存盘必须是c盘以外的;a+为 :有则输出 无则添加 print('hello world!',file=fp)#必须加file= fp.close()#关闭fp #不进行换行输出","分嗝 print('hello','world') #转义字符 print('hello\nworld')#换行 print('hello\tworld')#Tab print('hello\rworld')#回车 hello被覆盖 print('hello\bworld')#退格 print('http:\\www.baidu.com')#反斜杠 print('注意:当我们在正则表达式中表示反斜杠时,应写为“\\\\”,因为\在正则表达式中也是特殊字符,所以要用\\表示\,而两个\\就表示\\,再进行一次转义,才能表示\”') print('老师说;“大家好!”') print('老师说;’李姝婷是猪\'')#单引号需要转义 #原字符:不希望字符串中的转义字符起作用,就使用原字符 print(r'hello\tworld') print(chr(0b100111001011000)) print(ord('乘'))#十进制的乘 #识别字和保留字 #标识符:给对象起的名字(不能数字开头) import keyword print(keyword.kwlist)#查看保留字 name = 'bilibili' #多次幅值 被覆盖 name = '
python 基础源代码
最新推荐文章于 2024-05-26 06:15:00 发布