x新手入门
暴躁老哥学编程
别问,问就是暴躁
展开
-
题目:计算两个数字的最大公约数和最小公倍数
练习记录:python题目:计算两个数字的最大公约数和最小公倍数s=[0,0]print("Enter your number: ")for i in range(2): try: s[i]=eval(input()) except: print('something goes wrong,please enter again! ')a=...原创 2019-08-31 18:19:08 · 200 阅读 · 0 评论 -
题目:统计不同字符个数
Python练习记录题目:统计用户输入的字符串中不同字符个数(字母、数字、空格、其他)symble=input('Enter your words: ')number=space=other=letter=0i=0for i in range(len(symble)): if 'a'<symble[i]<'z' or 'A'<symble[i]<'Z':...原创 2019-08-31 18:52:52 · 5252 阅读 · 1 评论 -
题目:羊车门问题
Python练习题目:羊车门问题概率论没学好,理解起来好蛋疼,参考了一下其他人的:传送门1:link传送门2:linkimport randomcar_location=random.randint(1,3)totle=1000zhong=0buzhong=0for i in range(totle): first_choice=random.randint(1,3...原创 2019-08-31 21:08:05 · 865 阅读 · 0 评论 -
新手:Python文件读取时可能错误(个人收集)
错误一:读取文件时路径输入有误:f=open("D:\Python\Python37-32\a.txt","rt")#上述代码中“ \ ”符号在python中代表转义符,和某些字母连接时会产生错误运行结果:Traceback (most recent call last): File "<pyshell#2>", line 1, in <module> ...原创 2019-09-04 13:37:01 · 676 阅读 · 0 评论 -
Python语法里的坑收集
坑一:进行计算时先要定义变量,否则计算会报错对于只学过C的新手(比如我),会默认为设置一个变量后其默认值为零,但是python里并不是这样sum+=1新手可能会认为这样的输出结果是:1,but too naive,这样的结果如下:"C:\Users\DELL\Desktop\python practice\test\venv\Scripts\python.exe" "C:/Users/D...原创 2019-09-18 11:49:55 · 251 阅读 · 0 评论 -
利用Pycharm导入Python中的urllib2模块
一句话,py3里,urllib2貌似归到py自带的urllib.request中了,好像没必要安装…(⊙_⊙;)…原创 2019-09-25 21:03:55 · 7539 阅读 · 0 评论