Python语法学习笔记

1.转义字符

 文件地址可以在每个前添加,也可以在最前面加r

  print("C:\Users\panying\每日一练")

  print(r"C:Userspanying每日一练")

 转义字符不能放在最后 print("你好/n/")

2.换行

/n

print('''你好

我很好

你呢''')

3.字符串通过+ 拼接

print(520+1314)

5201314

4.字符串通过*来复制

print("我爱你 "*3)

我爱你

我爱你

我爱你

5.

3//2 地板除

3//2 = 1

-3//2=-2

6.求余数

3%2=1

7.

divmod(3,2)  结果为(1,1)

divmod(4,2) 结果为(2,0)

8.绝对值abs(-9)  9

9.绘图

import turtle

turtle.showturtle()

turtle.write()

turtle.right()

turtle.foword()

turtle.goto(a,b)

turtle.penup() 抬起笔

turtle.goto(100,200)

turtle.down()落笔

10.python变量和常量

python是地址赋值 可以改变数据类型

11.函数没有返回值 打印的值事none

 12.

打开一个文件

f=open("1.txt","wb")

f.close()

原文地址:https://www.cnblogs.com/yayayou/p/11698116.html