公司数字化运营转型,个人学习python,做点笔记。
我的第一行代码
print('hello,world')
输出结果:hello,world
单双引号的打印
#双引号
print('"hello python"')
print("'hello python'")
输出结果:“hello python”
‘hello python’
#三引号
print('''
我是一只小白,我喜欢敲代码,我热爱计算机
''')
输出结果:我是一只小白,我喜欢敲代码,我热爱计算机
占位符
#s = string 字符串 d = digital 数字 f = float 浮点数
name = 'heny'
age = 18
wife = 'lily'
city = 'HK'
height = 1.082321
print('我的名字是%s,我的年龄是%d,我的老婆是%s,我住在%s,我的身高是%.2f'%(name,age,wife,city,height))
输出结果:
我的名字是heny,我的年龄是18,我的老婆是lily,我住在HK,我的身高是1.08
转译符
#换行 \n = newline \n
print("abd\nefg")
#引号\' \" "I'm a boy"
print("I'm a boy")
#这个涉及到windows目录与Python认知目录的信息节点
print('c:\\windows\\python')
第一天学会的好玩的事
#提取码
import random #random标准库
all_raw_code = ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h']
my_code = [] #列表
for i in range(4):
gen_code = all_raw_code[random.randint(0,len(all_raw_code)-1)] #列表下标取值知识点
my_code.append(gen_code) #列表添加知识点
print('我的提取码为:',''.join(my_code))