Python编程从入门到实践(1)学习笔记

图灵程序设计丛书

Python编程从入门到实践

人民邮电出版社

以代码的形式,来学习python

本文是在window平台 安装的python3.8,开发工具用的Pycharm

第一章,第二章

 1 #!/usr/bin/env python3
 2 #上面一行可以在linux环境直接运行,win平台不行
 3 # $ chmod a+x hello.py
 4 
 5 100+ 200
 6 100 + 200 + 300
 7 print('hello world!')
 8 print(100 + 200 + 300)
 9 # 次方Power(2,10)
10 print(2**10)
11 
12 # 拼接打印字符串
13 print('The quick brown fox', 'jumps over', 'the lazy dog')
14 
15 print('100 + 200 =', 100 + 200)
16 
17 name = "test"
18 #name = input()
19 print(name)
20 
21 #这里是注释
22 #name = input('please enter your name: ')
23 print('hello,', name)
24 
25 # class Data Test:
26 a = 'a'
27 print(a)
28 
29 #字符串混排 转义
30 message = "i'm zc"
31 message = 'i"m zc call me "hello,world"'
32 message = "i'm zc call me \"zc\""
33 print(message)
34 message = "i\'m zc call me \"zc\""
35 print(message)
36 
37 s1 = "ada"
38 print(s1.title())
39 s1 = "ADA"
40 print(s1.title())
41 print("变小写:", s1.title().lower())
42 
43 #字符串拼接
44 first = "zhang"
45 last  = "san"
46 print(first + " " + last)
47 
48 #换行 指标位
49 print("zc:\nsecond line \taaa\nthird line")
50 
51 #去除空格
52 s2 ="  aaaa  "
53 print(s2.rstrip())
54 print(s2.lstrip())
55 print(s2.strip())
56 
57 #0.30000000000000004
58 print(0.2 + 0.1)
59 print(3*0.1)
60 
61 #浮点 python2 3/2=1  3.0/2=1.5
62 print(3/2)
63 print(3.0/2)
64 
65 #指导原则
66 import this

 

posted @ 2021-05-07 09:17  阿米诚  阅读(71)  评论(0编辑  收藏  举报