python入门学习笔记

公司数字化运营转型,个人学习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))

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值