摘要: 统计字符串里面有多少个阿拉伯数字。 s = "I am sylar, I'm 14 years old, I have 2 dogs!"count = 0for c in s: if c.isdigit(): count = count + 1print(count) 运行结果: 阅读全文
posted @ 2023-11-05 21:31 Thomas2023 阅读(9) 评论(0) 推荐(0) 编辑
摘要: 对字符串的内容进行遍历。 方法一: s="今天是星期一,大家都很忙!"count=0while count<len(s): print(s[count]) count+=1运行结果: 方法二: s="今天是星期一,大家都很忙!"for s1 in s: print(s1) 阅读全文
posted @ 2023-11-05 21:09 Thomas2023 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 利用while循环编写猜数字游戏: n = 66while True: num = input("猜测一下") if int(num) > n: print("猜大了") elif int(num) < n: print("猜小了") else : print("猜对了") break运行结果: 阅读全文
posted @ 2023-11-05 15:33 Thomas2023 阅读(61) 评论(0) 推荐(0) 编辑
摘要: 方法一:name=input('请输入姓名:')age=input('请输入年龄:')sex=input('请输入性别:')hobby=input('请输入爱好:')print(name+'今年'+age+'岁,'+'性别是'+sex+'的,爱好是'+hobby+'。')运行结果显示: 方法二: n 阅读全文
posted @ 2023-11-05 12:10 Thomas2023 阅读(1) 评论(0) 推荐(0) 编辑
摘要: count=1while count<=100: if count%2==1: print(count) count = count + 1运行结果显示: 阅读全文
posted @ 2023-11-05 11:45 Thomas2023 阅读(12) 评论(0) 推荐(0) 编辑
摘要: 方法一:sum=0for i in range(1,101,1): sum=sum+iprint(sum)运行以上代码,显示结果: 方法二: sum=0count=1while count<=100: sum=sum+count count=count+1 print(count)print(sum 阅读全文
posted @ 2023-11-05 10:08 Thomas2023 阅读(51) 评论(0) 推荐(0) 编辑
摘要: while中使用break和continue: count=0##计数器while True: s=input('请输入内容:') if s=='退出': print(count) print('退出!') break##退出循环 if '生气' in s: print(count) continu 阅读全文
posted @ 2023-11-05 09:59 Thomas2023 阅读(14) 评论(0) 推荐(0) 编辑
摘要: count=1while count<=8: print('干活!')#循环输出8次就停止 count+=1运行结果: 阅读全文
posted @ 2023-11-05 08:10 Thomas2023 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 以下为思路提供,因为涉及我的知识版权,所以不能完全公开具体的操作方法,只能提供大概思路,仅供参考,不构成任何买卖依据。 一、先从某APP 下载数据,以文本文件格式保存到本地盘。(至于如何下载,这个暂时不公开方法。) 二、1.txt文件内容的格式,对应某一个热门板块,以方便后面用kettle ETL工 阅读全文
posted @ 2023-11-05 01:23 Thomas2023 阅读(14) 评论(0) 推荐(0) 编辑
摘要: import tushare as tsimport pandas as pdfrom sqlalchemy import create_enginefrom psycopg2 import sqlimport datetimeimport cx_Oracle class Oracle(object 阅读全文
posted @ 2023-11-05 00:26 Thomas2023 阅读(90) 评论(0) 推荐(0) 编辑
摘要: import cx_Oracleclass Oracle(object): def __init__(self, user_name, password, host, instance): self._conn = cx_Oracle.connect('%s/%s@%s/%s' % (user_na 阅读全文
posted @ 2023-11-05 00:00 Thomas2023 阅读(216) 评论(0) 推荐(0) 编辑