随笔分类 -  python基础学习

摘要:# coding:utf-8 # temp = "hello\\world" # print temp # 原生字符串:raw 所见即所得 # raw_input # input # temp = r"hello\n\tworld" # print (temp) 阅读全文
posted @ 2019-07-15 22:58 水果、、 阅读(143) 评论(0) 推荐(0)
摘要:# coding:utf-8 # \ 续行符 编辑换行 # temp = 'hedsjakdlsadjaklddjakdldjakllllkdjhg\ # hjkkkkkkkkkkkkkkkkkkkkkkkkkkldhsdaggfkjdllsfjakld' # print(temp) # 三引号:所见即所得 # temp=""" # hello # world # """ # pr... 阅读全文
posted @ 2019-07-15 22:49 水果、、 阅读(835) 评论(0) 推荐(0)
摘要:# coding:utf-8 # 字符串常见操作 # 1.find # find:返回查找字符串的下标位置。如果返回-1,代表得是没有查找到该字符串。 # 'rfind'是从右往左。 # username = 'hello zhiliao' # index = username.find('zhiliao') # print(index) # 结果为6 # if index > 0: # ... 阅读全文
posted @ 2019-07-11 22:56 水果、、 阅读(727) 评论(0) 推荐(1)
摘要:# coding:utf-8 # 字符串常见操作 # 1.find # find:返回查找字符串的下标位置。如果返回-1,代表得是没有查找到该字符串。 # 'rfind'是从右往左。 # username = 'hello zhiliao' # index = username.find('zhiliao') # print(index) # 结果为6 # if index > 0: # ... 阅读全文
posted @ 2019-07-07 20:29 水果、、 阅读(135) 评论(0) 推荐(0)
摘要:# python 切片和range()用法# coding:utf-8# range(开始位置,结束位置+1)# string[开始位置:结束位置+1:步长] 开始位置都是闭区间,结束位置都是开区间 阅读全文
posted @ 2019-07-07 15:41 水果、、 阅读(801) 评论(0) 推荐(0)
摘要:# 字符串拼接 # coding:utf-8 # 1.采用‘+’号的形式 # a = 'hello' # b = 'world' # c = a +' ' + b # print(c) # 2.采用格式化的形式 # a = "__" # b = 'name' # # "__name__" # # c = a + b + a # c = "%s%s%s" % (a,b,a) # prin... 阅读全文
posted @ 2019-07-06 21:01 水果、、 阅读(568) 评论(0) 推荐(0)
摘要:1.在python中使用单引号或者双引号括起来的就是字符串。2. # 使用6个单引号或双引号 使字符串所见即所得3.在python2中,字符串分为两种类型,第一种是str,第二种是unicode,他们都是继承自basestring。4.在python3中,字符串分为两种类型,第一种是bytes,是p 阅读全文
posted @ 2019-07-06 20:47 水果、、 阅读(223) 评论(0) 推荐(0)
摘要:# coding:utf-8 for row in range(1,10): for column in range(1,row+1): print("%d*%d=%d " % (column,row,column*row),end = '') print("") 阅读全文
posted @ 2019-07-06 13:57 水果、、 阅读(264) 评论(0) 推荐(0)
摘要:# coding:utf-8 # greet = 'hello world' # for in 遍历字符串 # for x in greet: # print (x) # ================================================== # greet = 'python papijiang papa mama' # cou... 阅读全文
posted @ 2019-07-06 13:35 水果、、 阅读(293) 评论(0) 推荐(0)
摘要:# coding:utf-8 # 打印1到10之间的整数,不要把5打印出来 # index = 0 # while index < 10: # index += 1 # if index ==5: # continue #退出此次循环 # print(index) # 打印1-10之间的所有奇数 # index = 0 # while index < 10: # i... 阅读全文
posted @ 2019-07-06 11:14 水果、、 阅读(794) 评论(0) 推荐(0)
摘要:# coding:utf-8 # break/continue 只能在循环中使用,不能在其它地方使用,while、for循环中可以使用 # num = 1 # while num num: print('太大') else: print ('恭喜您!答对啦') breakss 阅读全文
posted @ 2019-07-06 10:56 水果、、 阅读(420) 评论(0) 推荐(0)
摘要:# coding:utf-8 # form_future_import print_function //在python2中引入python3中print函数的语法的语句 # 1.总共有9列 # 2.每行中的列数,就是当前的行号 # 3.乘式的第一个数代表得是列,第二个数代表行 row = 1 column = 1 while row <= 9: while column ... 阅读全文
posted @ 2019-07-05 21:11 水果、、 阅读(1930) 评论(0) 推荐(0)
摘要:# form_future_import print_function //在python2中引入python3中print函数的语法的语句 阅读全文
posted @ 2019-07-05 20:10 水果、、 阅读(564) 评论(0) 推荐(0)
摘要:# coding:utf-8 # num = 10 # value = int(input('请输入您的值:')) # if value num: # print('太大') # else: # print('恭喜您!答对了啦') # 改成循环的方式############################### # num = 10 # value = int(input(... 阅读全文
posted @ 2019-07-05 18:05 水果、、 阅读(186) 评论(0) 推荐(0)
摘要:# coding:utf-8 # 现在要从1到10打印数字 # 1. 代码相似度80%以上,print # 2. 不同的地方就是后面需要打印的东西,每次都是加1 # 3. 总共只有10句 # print'1' # ..... #print '10' # num = 1 # print (num) # num += 1 # print(num) # num += 1 # p... 阅读全文
posted @ 2019-07-05 17:11 水果、、 阅读(172) 评论(0) 推荐(0)
摘要:# coding:utf-8 # print('hello world') age = 18 if age >= 18: print('可以进入网吧') print('警察叔叔不会找你麻烦') else: print('不可以进入网吧') print('如果你偷偷潜入进去了,那么警察叔叔会找你麻烦') print('finished') 阅读全文
posted @ 2019-07-05 16:45 水果、、 阅读(232) 评论(0) 推荐(0)
摘要:# coding:utf-8 # 0:星期天 # 1-6:代表得是星期一到星期六 index = int(input('请输入星期数字:')) #或者index=int(index) if index == 0: print('星期天') elif index == 1: print('星期一') elif index == 2: print('星期二'... 阅读全文
posted @ 2019-07-05 16:10 水果、、 阅读(4243) 评论(0) 推荐(0)
摘要:coding:utf-8 True/False 1.bool数据类型 a = True b = False print(type(a)) print(type(b)) 2.if语句使用的语法和else语句 if False: print('success') else: print('fail') print ('finished') 比较运算符:‘==’,‘!=’,‘>’,'... 阅读全文
posted @ 2019-07-05 12:26 水果、、 阅读(975) 评论(0) 推荐(0)
摘要:#coding:utf-8# a = 11# 1.‘+’号运算符# b = 22# c= a+b# print(c)# a='hello'# b='world'# c=a+b# print(c)# 2.'-'号运算符 # 与加号对应 没有字符串减的功能# 3.‘*’号运算符# a = 2# b = 阅读全文
posted @ 2019-07-05 10:28 水果、、 阅读(237) 评论(0) 推荐(0)
摘要:# coding:utf-8# print ('abc')# 格式化打印# 整形# 字符串类型: %s# 浮点类型# 字符串变量类型的格式化 %s# name = 'zhiliao'# print('my name is %s' % name)# %表示占位 s代表字符串类型# 整型变量的格式化 %d# age = 2147483648# print ('my age is %d... 阅读全文
posted @ 2019-07-04 21:13 水果、、 阅读(698) 评论(0) 推荐(0)