![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
wjfqvi
这个作者很懒,什么都没留下…
展开
-
Python爬虫准备工作,ubuntu安装selenium和geckodriver
安装seleniumsudo apt-get install python3-pippip3 install selenium安装geckodriver (用于Firefox)在这里下载:https://github.com/mozilla/geckodriver/releasestar -zxvf geck [Tab]mv geck [Tab] /usr/local/bin...原创 2018-12-13 11:04:44 · 631 阅读 · 0 评论 -
用来处理gwdac网站爬取的实验数据的python代码
写了几个用来整理gwdac爬取的散射实验数据的python代码,在这里保存一下,免得以后找不到代码一把按组分类的实验数据转成一行一个数据点#This program transfer gwdac datas to one data point per lineimport osobslist = (["DSG","P","D","DT","AYY","AXX","AZZ","AZX"...原创 2019-04-12 20:38:00 · 213 阅读 · 0 评论 -
python在文件中写 '\b' 与 ' ' 的区别
python在文件中写 ‘\b’ ,在gedit里面显示正常,在sublime里面显示<0x08>,如果用fortran读文件,会出错,改为 ’ ’ 后sublime和fortran都正常了原创 2018-12-18 15:48:44 · 1818 阅读 · 0 评论 -
Python open语句读写文件
print('file1\n')a='lalala'file1=open('file1.txt','w')file1.write('this is line1\nthis is line2\n')file1.write(a)file1.write('\n')file1.close()print('\nfile2\n')file2=open('file1.txt','a')fil...原创 2018-12-20 21:48:56 · 376 阅读 · 0 评论 -
Python函数
def sayhello(): print('hello')def plus(a,b): print(a+b)def minus(a=4,b=2): print(a-b) a=5sayhello()plus(1,3)plus(a,3)minus(a)minus(6,1)minus()def locala(): a = 9 ...原创 2018-12-20 21:21:25 · 115 阅读 · 0 评论 -
Python if语句
x=1y=2z=3if x<y: print('x is less than y')if x<y<z: print('x is less than y and y is less than z')if x!=y: print('x is not equal to y') if y>z: print( 'y>...原创 2018-12-20 20:56:41 · 174 阅读 · 0 评论 -
python爬虫爬取nn-online的数据
写一个爬虫爬取nn-online.org的np散射的pwa93的各分波的理论值需要先安装Python3,Python-pip3,selenium,geckodriverpython crawler代码如下# Wang Jianfeng Dec 14 2018# python3# Install selenium first: pip3 install seleniumfrom se...原创 2018-12-14 15:34:13 · 253 阅读 · 0 评论 -
Python循环while和for
print('while loop 1')a=1while True: print(a) a=a+1 if a>5: breakprint('while loop 2')a=0while a<5: print(a) a=a+1print('for loop1')listb=[1,7,3,5,88,4,663]f...原创 2018-12-20 01:06:41 · 168 阅读 · 0 评论 -
Python 简单的运算
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 26 2018, 23:26:24) [Clang 6.0 (clang-600.0.57)] on darwinType "copyright", "credits" or "license()" for more information.>>> 1+34>>> 4-6-2..原创 2018-12-20 00:47:47 · 225 阅读 · 0 评论 -
Python 打印字符串
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 26 2018, 23:26:24) [Clang 6.0 (clang-600.0.57)] on darwinType "copyright", "credits" or "license()" for more information.>>> print('hello world')hello...原创 2018-12-20 00:38:55 · 5649 阅读 · 0 评论 -
python统计词频
wordlist = [] #一个列表,存放所有的词counter = {} #一个字典,key为词,value为计数fread = open('1.txt','r')while True: oneline = fread.readline() if not oneline: break oneline = oneline.rstrip() #去掉这一行的换行符 one...原创 2019-06-25 22:14:25 · 3408 阅读 · 0 评论