代码拉取完成,页面将自动刷新
同步操作将从 mktime/python-learn 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
'''
2020-03-25 23:39:54
这是给大家做的第二次python培训.
上次给大家讲了怎样安装python解释器,以及怎样编写一个最简单的python hello world程序。
这次主要讲python语法.
'''
# 内置数据类型
# 整型
age = 20
print(age)
print(type(age))
print("小明今年:" + str(age) + "岁了")
print('----------------------------------------')
# 浮点数
rate = 0.49
print(rate)
print(type(rate))
print('----------------------------------------')
# 字符串
name = "python"
print(name)
print(type(name))
print("人生苦短,我用" + name)
print('----------------------------------------')
# 列表
fruits = ['苹果', '香蕉', '橘子', '西瓜']
#print(fruits)
#print(type(fruits))
#print(fruits[0])
#print(fruits[1])
#print(fruits[1:])
#print(fruits[:1])
#print(fruits[-1:])
#print(fruits[:-1])
#print(fruits[:])
#print(fruits[1:2])
#fruits[0] = '梨子'
#print(fruits)
#print(fruits[:])
#print('----------------------------------------')
#fruits.append('火龙果')
#print(fruits)
#fruits.insert(0, '芒果')
#print(fruits)
#fruits.pop()
#print(fruits)
#fruits.reverse()
#print(fruits)
# 元组
foods = ('拌面', '烤肉', '大盘鸡')
print(foods)
print(type(foods))
print(foods[0])
#foods[0] = '凉皮'
print('----------------------------------------')
# 字典
profile = {}
print(profile)
print(type(profile))
profile['name'] = 'chengwei'
profile['email'] = 'chengwei@hmccb.com'
profile['sex'] = 'man'
print(profile)
print(profile.keys())
print(profile.values())
print(profile['name'])
for item in profile.keys():
print('[{0}]-->[{1}]'.format(item, profile[item]))
# 条件判断
price = 100
if price > 50:
print("多了")
else:
print("不多")
age = 30
if age <=6:
print("小朋友")
elif age <= 18:
print("青少年")
else:
print("成年人")
# for循环
foods = ['拌面', '烤肉', '大盘鸡']
for item in foods:
print(item)
# for循环遍历range迭代器
for i in range(10):
print(i)
# while循环
while len(foods) > 0:
print(foods[-1:])
foods.pop()
# while循环 模拟do-while 至少执行一次
count = 0
while True:
print("hahaha")
count += 1
if count > 3:
break
#def func2(name):
# print("语言:" + name)
#
#if __name__ == '__main__':
# func2("python")
# #func1(host='localhost', port=3306, username='root', passwd='123456', db='test')
#def func1(**kwargs):
# print(kwargs)
# print(type(kwargs))
# for key in kwargs:
# print('[%s]-->[%s]' % (key, kwargs[key]))
#
#if __name__ == '__main__':
# func1(host='localhost', port=3306, username='root', passwd='123456', db='test')
import os
os.chdir("D:\\")
files = os.listdir('.')
print(files)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。