repo_name stringclasses 400
values | branch_name stringclasses 4
values | file_content stringlengths 16 72.5k | language stringclasses 1
value | num_lines int64 1 1.66k | avg_line_length float64 6 85 | max_line_length int64 9 949 | path stringlengths 5 103 | alphanum_fraction float64 0.29 0.89 | alpha_fraction float64 0.27 0.89 |
|---|---|---|---|---|---|---|---|---|---|
ChanJeunlam/eddy_wave | refs/heads/master | #!/usr/bin/env python
import numpy as np
import matplotlib.pyplot as plt
import scipy.integrate as integrate
plt.ion()
f0 = 1e-4
u0 = 0.5
R0 = 40e3 # radius
vmax = 0.5 # m/s
def v1(rr):
v = -vmax*rr/R0*np.exp(-0.5*(rr/R0)**2)
# v = -vmax*np.tanh(rr/R0)/(np.cosh(rr/R0))**2/(np.tanh(1.0)/(np.cosh(1.0))*... | Python | 41 | 22.170732 | 133 | /analysis/ode_wave.py | 0.576842 | 0.489474 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
print('I will display the od number 1 through 9.')
for num in [1, 3, 5, 7, 9]:
print(num)
| Python | 5 | 27 | 50 | /global/simple_loop2.py | 0.571429 | 0.514286 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
total_seconds = float(input('Enter a number of seconds: '))
hours = total_seconds // 3600
minutes = (total_seconds // 60) % 60
seconds = total_seconds % 60
print('Here is the time in hours,minutes, and seconds:')
print('Hours:', hours)
print('minutes:', minutes)
print('seco... | Python | 10 | 32.599998 | 59 | /global/time_converter.py | 0.669643 | 0.636905 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
from Crypto.Cipher import AES
from Crypto import Random
from binascii import b2a_hex, a2b_hex
__author__ = 'florije'
class prpcrypt():
def __init__(self, key):
self.key = key
self.mode = AES.MODE_CBC
# 加密函数,如果text不足16位就用空格补足为16位,
# 如果大于16当时不是16的倍数,那就补足为16的倍数。
... | Python | 67 | 25.97015 | 67 | /other/aes_demo.py | 0.576646 | 0.526287 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
'''
'''
data = [1, 2, 3, 4]
# for i in data:
# for j in data:
# print('{a}{b}'.format(a=i, b=j), end=' ')
# 上下两种表达一样,都是生成两位数。
# for i in data:
# for j in data:
# print('%s%s' % (i, j), end=' ')
# 下面生成任意组合三位数。
# for i in data:
# for j in dat... | Python | 33 | 19.424242 | 65 | /21days/5_5.py | 0.445104 | 0.434718 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
"""
输出所有的水仙花数,把谓水仙花数是指一个数3位数,其各各位数字立方和等于其本身,
例如: 153 = 1*1*1 + 3*3*3 + 5*5*5
"""
def get_flower():
for i in range(1, 10):
for j in range(10):
for k in range(10):
s = 100*i + 10*j + k
h = i**3 + j**3 + k**3
... | Python | 18 | 21.777779 | 40 | /learn/004.py | 0.413625 | 0.343066 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8-*-
__author__ = 'manman'
import sys
print('The command line arguments are:')
for i in sys.argv:
print i
print '\n\nThe PRTHONPATH is', sys.path, '\n'
| Python | 10 | 16.700001 | 45 | /byte/chapter_9_1.py | 0.616667 | 0.611111 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
import jpype
__author__ = 'florije'
lib_base_path = r'E:\fuboqing\files\company\po_upnp\libs'
jar_list = ['commons-codec-1.10.jar', 'log4j-1.2.17.jar', 'chinapaysecure.jar', 'bcprov-jdk15on-154.jar']
class_path = ';'.join(['%s\%s' % (lib_base_path, jar) for jar in jar_list])
jpype.startJVM(j... | Python | 47 | 36.553192 | 122 | /other/python_java/java_sign.py | 0.65949 | 0.58187 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
for x in range(5):
print('Hello world')
| Python | 4 | 21.5 | 24 | /global/simple_loop4.py | 0.544444 | 0.522222 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
import requests
__author__ = 'florije'
res = requests.get('http://www.weather.com.cn/data/list3/city.xml', params={'level': 1}, headers={
'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6',
'Content-Type': 'text/xml',
'Host': ... | Python | 16 | 25.5625 | 109 | /other/requests_demo.py | 0.617371 | 0.556338 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
class Meta(type):
def __call__(*args):
print("meta call", *args)
return None
class C(metaclass=Meta):
def __init__(*args):
print("C init not called", args)
if __name__ == '__main__':
c = C()
print(c)
| Python | 18 | 15.222222 | 40 | /other/chap1key6.py | 0.493151 | 0.489726 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
import time
import random
import requests
from flask import Flask, request
from flask_sqlalchemy import SQLAlchemy
from flask_script import Manager, Shell, Server
from flask_migrate import Migrate, MigrateCommand
__author__ = 'florije'
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI... | Python | 355 | 29.909859 | 119 | /other/weather_data.py | 0.553723 | 0.543607 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
from lxml import etree
__author__ = 'florije'
tree = etree.parse('citylist.xml')
root = tree.getroot()
for subroot in root:
for field in subroot:
print 'number:', field.get('d1'), 'name_cn:', field.get('d2'), 'name_en:', field.get(
'd3'), 'prov_name:', field.get('d4')
| Python | 12 | 25.666666 | 93 | /other/lxml_demo.py | 0.58125 | 0.565625 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
monthly_pay = 5000.0
annual_pay = monthly_pay * 12
print('Your annual pay is $', \
format(annual_pay, ',.2f'), \
sep='')
| Python | 7 | 24.571428 | 35 | /global/dollar_display.py | 0.547486 | 0.497207 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
'''
总科目状态:1,未通过,2,补考,3,通过
1.输入两门成绩
2.第一门成绩大于60分即通过,不及格则未通过
3.第一门成绩及格而第二门成绩不及格,则显示‘补考’。
'''
'''
x = int(input('输入第一门课程成绩:'))
y = int(input('输入第二门课程成绩:'))
status = 0 # 总科目状态,0定义为未知。
if x >= 60:
if y < 60:
status = 2
else:
status = 3
else:
status... | Python | 39 | 14.153846 | 28 | /21days/4_3.py | 0.521959 | 0.47973 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
num1 = 127.899
num2 = 3465.148
num3 = 3.776
num4 = 264.821
num5 = 88.081
num6 = 799.999
print(format(num1, '7.2f'))
print(format(num2, '7.2f'))
print(format(num3, '7.2f'))
print(format(num4, '7.2f'))
print(format(num5, '7.2f'))
print(format(num6, '7.2f'))
| Python | 15 | 19.200001 | 27 | /global/columns.py | 0.620462 | 0.425743 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
amount_due = 5000.0
monthly_payment = amount_due / 12
# \可加可不加
print('The monthly payment is ' +\
format(monthly_payment, '.2f'))
| Python | 7 | 25.142857 | 37 | /global/formatting.py | 0.612022 | 0.562842 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'florije'
from crypto_py import Cryptor
import binascii
iv, encrypted = Cryptor.encrypt('fuboqing', Cryptor.KEY)
print "iv : %s" % iv
# => iv 6aa60df8ff95955ec605d5689036ee88
print "encrypted : %s" % binascii.b2a_base64(encrypted).rstrip()
# => encrypted r19YcF8gc8bgk5NNui6I3w=... | Python | 19 | 26.789474 | 64 | /other/aes_js_py/aes.py | 0.712121 | 0.645833 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
"""
用户输入两个数字,程序计算出这两个数字的最小公倍数。
百度关键字:辗转相除法
"""
"""
1.定义函数,引出俩数x,y
2.大数除以小数得一余数不为零时,小数继续除以该余数,直至余数为零停止
3.最小公倍数 = (x*y)/余数
"""
from fractions import gcd
def arb(x, y):
while y != 0:
x, y = y, x % y
return x
if __name__ == '__main__':
x = int(input('Pl... | Python | 40 | 15.8 | 43 | /learn/006.py | 0.483631 | 0.470238 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
aint = int(input('please input a int:'))
bint = int(input('please input a int:'))
cint = int(input('please input a int:'))
dint = int(input('please input a int:'))
fint = int(input('please input a int:'))
alst = [aint, bint, cint, dint, fint]
print(alst[1:4:2])
print(alst[... | Python | 11 | 28.90909 | 40 | /21days/3_2.py | 0.625 | 0.603659 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
'''输入3个整数,列表,求最小值'''
aint = int(input('please input a int:'))
bint = int(input('please input a int:'))
cint = int(input('please input a int:'))
alst = [aint, bint,cint]
print(min(alst))
| Python | 9 | 24.888889 | 40 | /21days/3_1.py | 0.611111 | 0.602564 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
for name in ['Winken', 'Blinken', 'Nod']:
print(name)
| Python | 4 | 25 | 41 | /global/simple_loop3.py | 0.538462 | 0.528846 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8-*-
__author__ = 'manman'
class Person:
pass
p = Person
print(p)
| Python | 10 | 8.2 | 22 | /byte/chapter_12_1.py | 0.543478 | 0.532609 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'florije'
from Crypto.Cipher import AES
# Encryption
encryption_suite = AES.new('This is a key123', AES.MODE_CBC, 'This is an IV456')
cipher_text = encryption_suite.encrypt("The answer is no")
print cipher_text['ciphertext']
# Decryption
decryption_suite = AES.new('This is a key12... | Python | 13 | 31.76923 | 80 | /other/aes_js_py/new/002.py | 0.720657 | 0.690141 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
high_score = 95
test1 = int(input('Enter the score for test 1:'))
test2 = int(input('Enter the score for test 2:'))
test3 = int(input('Enter the score for test 3:'))
average = (test1 + test2 + test3) / 3
print('The average score is', average)
if average >= high_score:
p... | Python | 11 | 33.81818 | 49 | /global/test_average.py | 0.650131 | 0.616188 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
for i in range(3):
for j in range(i, 3):
print('+', end='')
print()
print('women')
print('doushi', end='')
print('haohaizi.', end='\n')
| Python | 11 | 17.181818 | 28 | /21days/4_2.py | 0.505 | 0.49 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
first_name = 'Kathryn'
last_name = 'Marino'
print(first_name, last_name)
print(first_name, last_name)
| Python | 7 | 20.285715 | 28 | /global/string_variable.py | 0.64 | 0.633333 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'florije'
import urllib, json
import urllib.parse, urllib.request
query_args = {'pass': 'b6ce159334e155d8',
'word': 'U2FsdGVkX1/7IVjirkhwvDYzNDPDDyiDWbXHmETFG3+RlJtHwYBtXUL+tr3Gbu17/xak/TACBGRpGfsbEQdnnuwAGmVtf36QRsMHUWNv5hbyQ/+Ymf/J5REE94DfRqQUvOjeh6lbGz4VoblsXK54Aq... | Python | 15 | 29.466667 | 53 | /other/aes_js_py/urls.py | 0.643326 | 0.584245 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
first_name = input('Enter your first name: ')
last_name = input('Enter your last name: ')
print('Hello', first_name, last_name)
| Python | 6 | 28.166666 | 45 | /global/string_input.py | 0.627119 | 0.621469 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'florije'
"""
去除重复关键字,
'[a:1,b:2,c:3]','[a:7,c:2,m:7,r:4]','[a:3,b:2,c:7,o:5]'
"""
myseq = """[a:1,b:2,c:3]
[a:3,b:3,c:8]
[a:7,c:2,m:7,r:4]
[a:2,c:4,m:6,r:4]
[a:3,b:2,c:7,o:5]"""
res_keys, res_strs = [], []
for item in myseq.split('\n'):
# 获取key
item_keys = [raw_item.spl... | Python | 30 | 24.466667 | 90 | /other/problem01.py | 0.515707 | 0.472513 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8-*-
__author__ = 'manman'
def say(message, times=1):
print(message * times)
say('Hello')
say('World', 5)
def say(message, times=2):
print(message * times)
say('Hello', 2)
say('World', 4)
def say(message, times=1):
print(message * times)
say('Hate')
say('You', 1314)
| Python | 26 | 10.884615 | 26 | /byte/func_default.py | 0.588997 | 0.553398 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
print('''one
two
three''')
print('''one two three''')
print('''one, two, three''')
print('''one,
two,
three''')
print("one\n"
"two\n"
"three")
| Python | 17 | 11.058824 | 28 | /global/display_quote.py | 0.504854 | 0.5 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
import json
import urllib.request
"""
读取1.json文件内容,然后解析出来把mp3下载地址找到,然后下载mp3文件。
"""
# import os
#
# for r, ds, fs in os.walk("/home/test"):
# for f in fs:
# fn = os.path.join(r, f)
# if f == "A":
# print(os.path.abspath(fn))
#
#
# def file... | Python | 72 | 18.263889 | 72 | /learn/010.py | 0.545782 | 0.526316 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'florije'
"""
2.1 设计程序流程
设计程序-写代码-更正语法错误-测试程序-更正逻辑错误-继续循环
流程图的概念,稍后搜索学习。
"""
| Python | 9 | 11.888889 | 32 | /start/2_1/2_1.py | 0.59322 | 0.567797 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
amount_due = 5000.0
monthly_payment = amount_due / 12.0
print('The monthly payment is', monthly_payment)
| Python | 5 | 29.200001 | 48 | /global/no_formatting.py | 0.662252 | 0.602649 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8-*-
__author__ = 'manman'
# Filename: mymodule_demo.py
import mymodule
mymodule.say_hi()
print('Version', mymodule.__version__)
| Python | 9 | 15.777778 | 38 | /byte/mymodule_demo.py | 0.640523 | 0.633987 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
test1 = float(input('Enter the first test score: '))
test2 = float(input('Enter the second test score: '))
test3 = float(input('Enter the third test score: '))
average = (test1 + test2 + test3) / 3.0
print('The average score is', average)
| Python | 7 | 39.714287 | 53 | /global/test_score_average.py | 0.65614 | 0.624561 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8-*-
__author__ = 'manman'
def func(a, b=5, c=10):
print 'a is', a, 'b is', b, 'c is', c
func(3, 7)
func(25, c=24)
func(c=50, a=100)
func(a=3)
def show_info(name, age=20, *args, **kwargs):
"""
show student's info
:param name: student's name
:param age: student's age
:par... | Python | 40 | 18.65 | 53 | /byte/func_key.py | 0.520966 | 0.453621 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'florije'
def pydanny_selected_numbers():
# If you multiple 9 by any other number you can easily play with
# numbers to get back to 9.
# Ex: 2 * 9 = 18. 1 + 8 = 9
# Ex: 15 * 9 = 135. 1 + 3 + 5 = 9
# See https://en.wikipedia.org/wiki/Digital_root
yie... | Python | 25 | 21.879999 | 68 | /other/yields/yielding.py | 0.561189 | 0.5 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'florije'
# Program 2-1 练习单引号使用
print('Kate Austen')
print('123 Full Circle Drive')
print('Asheville, NC 28899')
| Python | 7 | 19.857143 | 30 | /start/2_2/output.py | 0.630137 | 0.554795 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
max_temp = 102.5
temperature = float(input("Enter the substance's Celsius temperature: "))
while temperature > max_temp:
print('The temperature is too high.')
print('Turn the thermostat down and wait')
print('5 minutes.Then take the temperature')
print('agai... | Python | 12 | 39.5 | 73 | /global/temperature.py | 0.695473 | 0.679012 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'florije'
"""
http://www.cnblogs.com/xiongqiangcs/p/3416072.html
"""
unitArab = (2, 3, 4, 5, 9)
unitStr = u'十百千万亿'
unitStr = u'拾佰仟万亿'
# 单位字典unitDic,例如(2,'十')表示给定的字符是两位数,那么返回的结果里面定会包含'十'.3,4,5,9以此类推.
unitDic = dict(zip(unitArab, unitStr))
numArab = u'0123456789'
numStr = u'零一二三四五六... | Python | 62 | 28.032259 | 103 | /other/alabo.py | 0.504444 | 0.450556 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
min_salary = 30000.0
min_years = 2
salary = float(input('Enter your annual salary:'))
years_on_job = int(input('Enter the number of ' +
'years employed:'))
if salary >= min_salary and years_on_job >= min_years:
print('You qualify for the loan.'... | Python | 12 | 30.25 | 54 | /global/loan_qualifier2.py | 0.608 | 0.586667 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8-*-
__author__ = 'manman'
for i in range(1, 5, 2):
print(i)
else:
print('The for loop is over')
for i in range(1, 5):
print(i)
else:
print('The for loop is over')
| Python | 12 | 15.666667 | 33 | /byte/for..in.py | 0.555 | 0.525 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
"""
编写程序,判断给定的某个年份是否是闰年。
闰年的判断规则如下:
(1)若某个年份能被4整除但不能被100整除,则是闰年。
(2)若某个年份能被400整除,则也是闰年。
"""
def leap_year(year):
if year % 4 == 0 and year % 100 != 0 or year % 400 == 0:
print('{year} year is leap year!'.format(year=year))
else:
print('{year} year... | Python | 21 | 20.857143 | 64 | /learn/001.py | 0.588235 | 0.544662 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'florije'
"""
<script type="text/javascript">var fish=1734+473;var frog=435+2716^fish;var seal=168+8742^frog;var chick=7275+2941^seal;var snake=3820+4023^chick;</script>
以上script脚本提取变量为字典。
"""
| Python | 7 | 32 | 155 | /learn/012.py | 0.69697 | 0.532468 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
import urllib
from lxml import etree
__author__ = 'florije'
def get_html(url):
page = urllib.urlopen(url)
html = page.read()
return html
def get_key(html):
page = etree.HTML(html.lower().decode('gb2312'))
trs = page.xpath(u"//td[@valign='top']/font[@size='2']//table[con... | Python | 34 | 21.647058 | 95 | /other/proxy.py | 0.505195 | 0.480519 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
# this program displays a person's name and address
print('Kate')
print('123 Full circle Drive')
print('Asheville, NC 28899')
| Python | 7 | 23.714285 | 51 | /global/comment1.py | 0.67052 | 0.618497 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
start_speed = 60 # Starting speed
end_speed = 131 # Ending speed
increment = 10 # Speed increment
conversion_factor = 0.6214 # Conversation factor
print('KPH\tMPH')
print('--------')
for kph in range(start_speed, end_speed, increment):
mph = kph * conversion_factor... | Python | 12 | 29.166666 | 52 | /global/speed_converter.py | 0.640884 | 0.60221 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'florije'
a = [1, 2, 3]
b = [item for item in a]
tmp = []
for item in a:
tmp.append(item)
print b, tmp
| Python | 9 | 15.111111 | 24 | /other/for.py | 0.531034 | 0.503448 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'florije'
from Crypto.Hash import SHA512
import cgi, base64
from Crypto.PublicKey import RSA
from Crypto.Signature import PKCS1_v1_5
from Crypto.Hash import SHA
h = SHA512.new()
h.update(b'Hello')
print h.hexdigest()
"""
先生成rsa的公私钥:
打开控制台,输入 openssl
再输入 genrsa -out private.pem... | Python | 68 | 18.852942 | 205 | /other/crys.py | 0.679259 | 0.622222 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
"""
1.判断用户输入的年月日,然后判断这一天是当年的第几天。
2.随机生成20个10以内的数字,放入数组中,然后去掉重复的数字。然后打印数组。
"""
# 根据出生年先判断是平年还是闰年,得出2月份天数,各月份天数相加即可。
# year = int(input("请输入年份: "))
# march = int(input("请输入月份: "))
# days = int(input("请输入日子: "))
# def feb_days():
# for i in range():
# if yea... | Python | 61 | 21.721312 | 104 | /learn/008.py | 0.52886 | 0.474747 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8-*-
__author__ = 'manman'
def total(initial=5, *numbers, **keywords):
count = initial
for number in numbers:
count += number
for key in keywords:
count += keywords[key]
return count
print(total(10, 1, 2, 3, vegetables=50, fruits=100))
def add(a, b, c):
if a =... | Python | 24 | 15.916667 | 52 | /byte/VarArgs.py | 0.539409 | 0.5 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
user_infos = [{'name': 'john', 'password': '2354kdd', 'usertype': 1},
{'name': 'kate', 'password': '3574kdd', 'usertype': 2}]
def login(name, password):
"""
用户登录
:param name:
:param password:
:return:
"""
for user in user_infos:
... | Python | 30 | 24.333334 | 72 | /21days/5_4.py | 0.536842 | 0.532895 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
min_salary = 30000.0
min_years = 2
salary = float(input('Enter your annual salary:'))
years_on_job = int(input('Enter the number of' +
'years employed:'))
if salary >= min_salary:
if years_on_job >= min_years:
print('You quality for the loan.')
els... | Python | 18 | 31.055555 | 50 | /global/loan_qualifier.py | 0.55286 | 0.537262 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
"""
求 2/1+3/2+5/3+8/5+13/8.....前20项之和?
"""
a = 1.0
b = 2.0
sum = 0
c = 0
for i in range(0, 20):
sum = sum + b/a
c = a + b
a = b
b = c
print(sum)
| Python | 17 | 11.529411 | 34 | /learn/005.py | 0.415888 | 0.308411 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
first_name = 'ww'
last_name = 'rr'
print('I am a teacher', \
first_name, \
last_name)
print('a', 'b', 'c', end=';')
print('a', 'b', 'c', sep='**')
print(1, 2, 3, 4, sep='')
print('****\n*\n****\n* *\n****')
print('****')
print('*')
print('* *')
print('* ... | Python | 26 | 16.115385 | 34 | /21days/2_1.py | 0.455157 | 0.441704 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'florije'
"""
练习双引号使用
"""
print("Kate Austen")
print("123 Full Circle Drive")
print("Asheville, NC 28899")
| Python | 10 | 13.1 | 30 | /start/2_2/double_quotes.py | 0.588652 | 0.524823 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8-*-
__author__ = 'manman'
print 'Simple Assignment'
shoplist = ['apple', 'mango', 'carrot', 'banana']
mylist = shoplist
del shoplist[0]
print 'shoplist is', shoplist, id(shoplist)
print 'mylist is', mylist, id(mylist)
print 'Copy by making a full slice'
mylist = shoplist[:]
del mylist[0]
print... | Python | 20 | 18.85 | 49 | /byte/chapter_10_5.py | 0.680101 | 0.672544 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8-*-
__author__ = 'manman'
# !/usr/bin/python
# Filename: str_format.py
age = 25
name = 'Swaroop'
print (' {0} is {1} years old'.format(name, age))
print('Why is {0} playing with that python?'.format(name))
print('{:3}'.format('hello'))
print('{:<11}'.format('hello'))
print('{:>11}'.format('hello'))... | Python | 17 | 25.705883 | 58 | /byte/format.py | 0.592511 | 0.550661 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'florije'
import re
import json
import time
import random
import requests
import datetime
import requesocks
from bs4 import BeautifulSoup
def test_url_available(url):
proxies = {
'http': 'http://{url}'.format(url=url),
# 'http': 'http://222.88.142.51:8000',
... | Python | 147 | 36.707481 | 163 | /other/jiandan/proxy.py | 0.586686 | 0.533285 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
# Create two variables: top_speed and distance.
top_speed = 160
distance = 300
# Display the values referenced by the variables.
print('The top speed is')
print(top_speed)
print('The distance traveled is')
print(distance)
| Python | 12 | 21.5 | 49 | /global/variable_demo2.py | 0.707407 | 0.681481 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
myseq = """[a:1, b:2, c:3]
[a:3, b:3, c:8]
[a:7, c:2, m:7, r:4]
[a:2, c:4, m:6, r:4]
[a:3, b:2, c:7, o:5]"""
res_keys = []
res_strs = []
# res = [item[1: len(item) - 1].split(',') for item in myseq.split('\n')]
# print res
for item in myseq.split('\n'):
# item_list ... | Python | 35 | 27.285715 | 90 | /21days/4_5.py | 0.500502 | 0.474423 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
#.adct = {'a': 1, 'b': 2, 'c': 3}
#.print(adct)
# adct = {'a': 1, 'b': 2}
# adct.update({'c': 3})
# print(adct)
# d1,d2,d3是三种不同的表达形式,
d1 = dict((['a', 1], ['b', 2],['c', 3]))
d2 = dict(a=1, b=2,c=3)
d3 = {'a': 1, 'b': 2, 'c': 3}
print(d1)
print(d2)
print(d3)
| Python | 17 | 17.117647 | 40 | /21days/3_3.py | 0.448387 | 0.367742 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
"""
壹、贰、叁、肆、伍、陆、柒、捌、玖、拾、佰、仟、万
11111
壹万壹仟壹佰壹拾壹
"""
map_value_dict = {'0': '零', '1': '壹', '2': '贰', '3': '叁', '4': '肆', '5': '伍', '6': '陆', '7': '柒', '8': '捌',
'9': '玖'}
map_unit_dict = {2: '拾', 3: '佰', 4: '仟', 5: '万'}
result = []
def convert_num_str(n... | Python | 70 | 28.085714 | 107 | /global/0.0shuzizhuanhuan.py | 0.481845 | 0.454858 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
function_class = (lambda x: x).__class__
print(function_class)
def foo():
print("hello world.")
def myprint(*args, **kwargs):
print("this is my print.")
print(*args, **kwargs)
newfunc1 = function_class(foo.__code__, {'print': myprint})
newfunc1()
newfunc2... | Python | 20 | 19.75 | 91 | /other/functions.py | 0.619277 | 0.607229 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
original_price = float(input("Enter the item's original price: "))
discount = original_price * 0.2
sale_price = original_price - discount
print('The sale price is', sale_price)
| Python | 7 | 31 | 66 | /global/sale_price.py | 0.678571 | 0.665179 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8-*-
__author__ = 'manman'
class Person:
def __init__(self, name):
self.name = name
def say_hi(self):
print 'Hello, my name is', self.name
p = Person('Swaroop')
p.say_hi()
| Python | 14 | 14.642858 | 44 | /byte/chapter_12_3.py | 0.538813 | 0.534247 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
room =1002
print('I am staying in room number')
print(room)
room = 503
print('I am staying in room number', room)
| Python | 9 | 17 | 42 | /global/variable_demo3.py | 0.638037 | 0.588957 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
aint = int(input('please input a int:'))
bint = int(input('please input a int:'))
cint = int(input('please input a int:'))
dint = int(input('please input a int:'))
fint = int(input('please input a int:'))
gint = int(input('please input a int:'))
hint = int(input('please in... | Python | 19 | 29.947369 | 67 | /21days/3_4.py | 0.643463 | 0.641766 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'florije'
import base64
from Crypto.Cipher import AES
from pkcs7 import PKCS7Encoder
# 使用256位的AES,Python会根据传入的Key长度自动选择,长度为16时使用128位的AES
key = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
mode = AES.MODE_CBC
iv = '1234567812345678' # AES的CBC模式使用IV
encoder = PKCS7Encoder()
text = "This is... | Python | 35 | 22.6 | 51 | /other/aes_js_py/encrypt.py | 0.717576 | 0.671515 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
'''
1.输入20个数
2.收入一个列表
3.按正负数分入两个列表
'''
source_list = []
positive_list = []
negative_list = []
for i in range(20):
num = int(input('Please input the number:'))
print(num)
source_list.append(num)
print('source list data is:')
print(source_list)
for item in so... | Python | 31 | 15.967742 | 48 | /21days/4_4.py | 0.634981 | 0.617871 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'florije'
import time
import requests
from bs4 import BeautifulSoup
def sign_daily(username, password):
username = username # username
password = password # password
singin_url = 'https://v2ex.com/signin'
home_page = 'https://www.v2ex.com'
daily_url = 'https... | Python | 65 | 30.4 | 120 | /other/signvto.py | 0.598236 | 0.577658 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
salary = 2500.0
bonus = 1200.0
pay = salary + bonus
print('Your pay is', pay)
| Python | 7 | 16.857143 | 25 | /global/simple_math.py | 0.592 | 0.504 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8-*-
__author__ = 'manman'
def say_hi():
print('Hi,this is mymodule speaking.')
__version__ = '0.1'
| Python | 9 | 13 | 42 | /byte/mymodule.py | 0.53125 | 0.507813 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'florije'
def reverse(text):
return text[::-1]
def is_palindrome(text):
return text == reverse(text)
something = raw_input("Enter input: ")
if is_palindrome(something):
print "Yes,it is a palindrome"
else:
print"No,it is not a palindrome"
| Python | 17 | 16.529411 | 38 | /byte/chapter_13_1.py | 0.637584 | 0.630872 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
hours = int(input('Enter the hours worked this week: '))
pay_rate = float(input('Enter the hourly pay rate: '))
gross_pay = hours * pay_rate
print('Gross pay: $', format(gross_pay, ',.2f'))
| Python | 6 | 38.333332 | 56 | /global/gross_pay.py | 0.631356 | 0.622881 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
# This program demonstrates a variable.
room = 503
print('I am staying in room number.')
print(room)
| Python | 7 | 20.142857 | 39 | /global/variable_demo.py | 0.655405 | 0.628378 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
"""
根据用户输入打印正三角,比如用户输入3打印如下:
*
*
* *
*
* *
* * *
打印菱形
"""
# 1. 三角形
# def show_triangle(num):
# """
# print triangle
# :param num:
# :return:
# """
# for i in range(num):
# # print('i%s' % i)
# print(' ' * (num - i - 1), e... | Python | 61 | 14.557377 | 60 | /learn/007.py | 0.419389 | 0.404636 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
"""
1,定义函数get_blank_count
2,该函数获取字符串空格
3,测试该方法
"""
def get_blank_count(strs):
"""
获取字符串中空格数目
:param strs: 传入原始字符串
:return: 返回字符串中空格数目
"""
count = 0
for item in strs:
if item == ' ':
count += 1
return count
if __name__ ... | Python | 26 | 16 | 43 | /21days/5_2.py | 0.547511 | 0.533937 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
'''
1,写一个function
2,这个函数是排序列表使用
3,写调用function
'''
# alist = [8, 4, 7, 12, 10, 9, 16]
# alist.sort() # 默认按升序排列
# print(alist)
# alist.sort(reverse=True) # 按降序排列
# print(alist)
#
# alist = [(3, 'ab'), (13, 'd'), (2, 'ss'), (101, 'c')]
# alist.sort()
# print(alist)
def s... | Python | 28 | 15.071428 | 55 | /21days/5_1.py | 0.535556 | 0.482222 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
print('I will display the number 1 through 5.')
for num in [1, 2, 3, 4, 5]:
print(num)
| Python | 5 | 26.4 | 47 | /global/simple_loop1.py | 0.557143 | 0.5 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8-*-
__author__ = 'manman'
def func_outer():
x = 2
print('x is', x)
def func_inner():
nonlocal x # zhe li bu dui ya. bu dong.
x = 5
func_inner()
print('Changed local x to', x)
func_outer()
| Python | 18 | 13.388889 | 48 | /byte/func_nonlocal.py | 0.482625 | 0.471042 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'florije'
"""
2.2 输入,执行,输出
"""
print('Hello world')
| Python | 9 | 9.222222 | 23 | /start/2_2/2_2.py | 0.5 | 0.467391 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
"""
1,给定字符串,带分行,然后split(分裂)为list
2,分析list每个元素,判断是否有href关键字,保存有关键字的数据
3,提取剩余元素里面的href=开头的部分
"""
def get_hrefs(str_data):
"""
获取str_data里面所有超链接
:param str_data:
:return:
"""
# split str_data to list
str_list = str_data.split('\n') # 分析原始数据看到有回车... | Python | 47 | 26.553192 | 100 | /21days/5_3.py | 0.485339 | 0.466049 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8-*-
__author__ = 'manman'
tabby_cat = "\tI'm tabbed in."
persian_cat = "I'm split non a line."
backslash_cat = "I'm \\ a \\cat."
| Python | 6 | 23.833334 | 37 | /hard/ex10.py | 0.56 | 0.553333 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
"""
遍历文件夹jsons,获取所有文件内容,并保存文件title到一个list里面并打印。
"""
import os
import json
base_path = '{base_path}\\jsons'.format(base_path=os.getcwd())
def get_content(filename):
"""
从filename读取数据
:param filename:
:return:
"""
result = ''
with open(filenam... | Python | 53 | 17.943396 | 95 | /learn/011.py | 0.570717 | 0.569721 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'florije'
import binascii
import StringIO
from Crypto.Cipher import AES
KEY = 'ce975de9294067470d1684442555767fcb007c5a3b89927714e449c3f66cb2a4'
IV = '9AAECFCF7E82ABB8118D8E567D42EE86'
PLAIN_TEXT = "ciao"
class PKCS7Padder(object):
'''
RFC 2315: PKCS#7 page 21
Some c... | Python | 98 | 30.775511 | 88 | /other/cryptojs_aes.py | 0.610469 | 0.558767 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
print('This program displays a list of number')
print('and their squares.')
start = int(input('Enter the starting number: '))
end = int(input('How high should I go?'))
print()
print('Number\tSquare')
print('--------------')
for number in range(start, end + 1):
square = ... | Python | 12 | 29.333334 | 49 | /global/user_squares1.py | 0.618132 | 0.60989 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
dollars = 2.75
print('I have', dollars, 'in my account.')
dollars =99.95
print('But now I have', dollars, 'in my account!')
| Python | 7 | 23.428572 | 50 | /global/variable_demo4.py | 0.606936 | 0.560694 |
florije1988/manman | refs/heads/master | # -*- coding: utf-8 -*-
__author__ = 'manman'
"""
编写程序求 1+3+5+7+……+99 的和值。
"""
'''
1.定义一组数列
2.求和
'''
def get_res():
source = range(1, 100, 2)
sum = 0
for i in source:
print(i)
sum += i
return sum
if __name__ == '__main__':
res = get_res()
print(res)
| Python | 23 | 11.782609 | 29 | /learn/002.py | 0.452381 | 0.401361 |
dronperminov/Word2VecCodeNames | refs/heads/master | import json
import os
from math import sqrt
import re
def norm(vec):
dot = 0
for v in vec:
dot += v*v
return sqrt(dot)
def main():
filename = 'embedding.txt'
embedding = dict()
with open(filename, encoding='utf-8') as f:
args = f.readline().strip('\n').split(' ')
e... | Python | 42 | 22 | 71 | /scripts/convert.py | 0.524845 | 0.519669 |
justincohler/opioid-epidemic-study | refs/heads/master | import pandas as pd
import json
def write_county_json():
tsv = pd.read_csv("../data/county_fips.tsv", sep='\t')
tsv = tsv[["FIPS", "Name"]]
print(tsv.head())
county_json = json.loads(tsv.to_json())
print(county_json)
with open('county_fips.json', 'w') as outfile:
json.dump(county_jso... | Python | 25 | 30.440001 | 72 | /choropleth/scripts/convert_fips.py | 0.616561 | 0.612739 |
jeffcheung2015/gallery_django_reactjs | refs/heads/master | """backend URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based... | Python | 50 | 38.119999 | 93 | /backend/backend/urls.py | 0.706033 | 0.699898 |
jeffcheung2015/gallery_django_reactjs | refs/heads/master | from django import forms
from .models import Image, Profile
from django.contrib.auth.models import User
from django.db import models
class UpsertImageForm(forms.ModelForm):
class Meta:
model = Image
fields = ["image_name", "image_desc", "image_file", "user", "tags"]
class UpdateUserForm(forms.Mode... | Python | 20 | 25.4 | 75 | /backend/gallery/forms.py | 0.662879 | 0.662879 |
LeeHanYeong/CI-Test | refs/heads/master | from django.test import TestCase
class SampleTest(TestCase):
def test_fail(self):
self.assertEqual(2, 1)
| Python | 6 | 18.833334 | 32 | /app/ft/tests.py | 0.697479 | 0.680672 |
ajhoward7/Machine_Learning | refs/heads/master | from .imports import *
from .torch_imports import *
from .core import *
import IPython, graphviz
from concurrent.futures import ProcessPoolExecutor
import sklearn_pandas, sklearn, warnings
from sklearn_pandas import DataFrameMapper
from sklearn.preprocessing import LabelEncoder, Imputer, StandardScaler
from pandas.ap... | Python | 129 | 41.550388 | 116 | /ML/fastai/structured.py | 0.645537 | 0.638251 |
olof98johansson/SentimentAnalysisNLP | refs/heads/main | import train
import preprocessing
def run():
'''
Training function to run the training process after specifying parameters
'''
preprocessing.config.paths = ['./training_data/depressive1.json',
'./training_data/depressive2.json',
'./t... | Python | 43 | 48.674419 | 143 | /main.py | 0.534612 | 0.50608 |
olof98johansson/SentimentAnalysisNLP | refs/heads/main | import torch
import torch.nn as nn
import models
import preprocessing
from collections import defaultdict
import time
import os
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style('darkgrid')
from celluloid import Camera
def Logger(elapsed_time, epoch, epochs, tr_loss, tr_acc, val_l... | Python | 234 | 36.901711 | 106 | /train.py | 0.618002 | 0.599414 |
olof98johansson/SentimentAnalysisNLP | refs/heads/main | # NOTE: TWINT NEEDS TO BE INSTALLEED BY THE FOLLOWING COMMAND:
# pip install --user --upgrade git+https://github.com/twintproject/twint.git@origin/master#egg=twint
# OTHERWISE IT WON'T WORK
import twint
import nest_asyncio
nest_asyncio.apply()
from dateutil import rrule
from datetime import datetime, timedelta
def g... | Python | 93 | 31.838709 | 109 | /twint_scraping.py | 0.644728 | 0.632613 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.