- 入门教程
https://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000 廖雪峰的教程
2、python基础
print("hello python")
print("100+200","=",100+200)
a = 100
if a>=0:
print(a)
else:
print(-a)
print(r'\\\t\\\\')
print('''line1
line2
line3''')
print(r'''hello,\n
world''')
print(3>2)
print(3<2)
print(True and True)
print(True and False)
print(True or False)
print(True or True)
print(not True)
a = 123
print(a)
a = "ABC"
print(a)
print(10/3)
print(9/3)
print(10//3)
print(10%3)
print(ord('A'))
print(ord('中'))
print(chr(66))
print(chr(25991))
x = b'ABC'
print(x)
print('ABC'.encode('ascii'))
print("中文".encode('utf-8'))
print(len("ABC"))
print(len("中文"))
print(len(b'ABC'))
print(len('中文'.encode('utf-8')))
print('%2d-%02d' % (3,1))
print('%.2f' % 3.1415926)
print('Age: %s. Gender: %s' %(25,True))
print('growth rate: %d %%' % 7)
formates = 'Hello,{0},成绩提升了 {1:.1f}%'.format('小明',17.25)
print(formates)
classmate = ['Alice','Bob','Tom']
print(classmate)
print(len(classmate))
print(classmate[0])
print(classmate[-1])
print(classmate[-2])
classmate.append('Adam')
print(classmate)
classmate.insert(1,'jack')
print(classmate)
classmate.pop()
print(classmate)
classmate.pop(1)
print(classmate)
classmate[1]='Sarah'
print(classmate)
s = ['python','java',['asp','php'],'scheme']
print(s[2][1])
classmate = ('michael','Bob','Tracy')
t = (1,)
t = ('a','b',['A','B'])
t[2][0] = 'X'
t[2][1] = 'Y'
print(t)
age = 5
if age >=18:
print('your age is',age)
print('adult')
elif age>=6:
print('kid')
else:
print('your age is',age)
print('teenager')
s = '1982'
birth = int(s)
if birth<2000:
print('00前')
else:
print('00后')
namse = ['Alice','Bob','Tracy']
for name in namse:
print(name)
sum = 0
for x in [1,2,3,4,5,6,7,8,9,10]:
sum = sum + x
print(sum)
s = list(range(101))
print(s)
sum = 0
for x in range(101):
sum = sum + x
print(sum)
sum = 0
n = 99
while n>0:
sum = sum + n
n = n - 2
print(sum)
n = 1
while n <= 100:
if n > 10:
break
print(n)
n = n+1
print('END')
d = {'Michael': 95,'Bob':75, 'Tracy':85}
print('Michael score',d['Michael'])
d['Adam'] = 67
print('Adam score',d['Adam'])
print('THomas' in d)
print(d.get('ssss'))
d.pop('Bob')
s = set([1,2,3])
print(s)
s = set([1,1,2,2,3,3])
print(s)
s.add(4)
print(s)
s.remove(4)
print(s)