05 2020 档案

摘要:my_set = set() #create a new set, 虽然set的显示结果为{item, item1...},但是不能用{}来创建集合,应该{}默认是创建dict print(help(my_set)) #查看帮助 my_set.add('jerry') #添加元素用add,而非lis 阅读全文
posted @ 2020-05-31 09:58 profesor 阅读(319) 评论(0) 推荐(0) 编辑
摘要:#!/bin/bash #用while loop计算1到100的和 num=1 sum=0 while [ $num -lt 101 ]; do sum=$(($sum+$num)) num=$(($num+1)) done printf "sum is %s\n" $sum #!/bin/bash 阅读全文
posted @ 2020-05-30 22:37 profesor 阅读(309) 评论(0) 推荐(0) 编辑
摘要:vim打开 vim ~/.vimrc 添加 syntax on #语法高亮set number #显示行数 set hlsearch set tabstop=4 set autoindent 阅读全文
posted @ 2020-05-30 20:48 profesor 阅读(161) 评论(0) 推荐(0) 编辑
摘要:当需要输入密码时,为了保证密码不在屏幕上显示出来,可以考虑import getpass from getpass import getpass username = input('input your username: ') if username == 'jerry': password = g 阅读全文
posted @ 2020-05-30 15:41 profesor 阅读(331) 评论(0) 推荐(0) 编辑
摘要:Python: #计算并输出1~100之间的奇数之和与偶数之和 from functools import reduce print("evenSum=",end='') print(reduce(lambda a, b: a + b, filter(lambda i: i%2 == 0, [i f 阅读全文
posted @ 2020-05-29 14:13 profesor 阅读(4229) 评论(0) 推荐(0) 编辑
摘要:1. #快速生成1,2,3,..., 100数字列表: print([i for i in range(1,101)]) 2. #快速生成001,002,003,...,100数字列表: print([f"{i:03}" for i in range(1,101)]) 或者不用f-string pr 阅读全文
posted @ 2020-05-29 09:07 profesor 阅读(2338) 评论(0) 推荐(1) 编辑
摘要:Java import java.util.Scanner; public class compare { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print 阅读全文
posted @ 2020-05-29 08:57 profesor 阅读(622) 评论(0) 推荐(0) 编辑
摘要:用Python处理/生成JSON文件 先看个python list/array: my_list = [ {"Jerry": {"job": "comedian", "age": 34, "married": True,},}, {"Elaine": {"job": "housewife", "ag 阅读全文
posted @ 2020-05-28 16:14 profesor 阅读(569) 评论(0) 推荐(0) 编辑
摘要:String.format(); System.out.printf(); System.out.format() 阅读全文
posted @ 2020-05-27 11:02 profesor 阅读(286) 评论(0) 推荐(0) 编辑
摘要:JAVA: import static java.lang.System.out; public class Ternary { public static void main(String[] args) { int a = 4, b = 5; out.println(++a == b-- ? a 阅读全文
posted @ 2020-05-27 09:45 profesor 阅读(200) 评论(0) 推荐(0) 编辑
摘要:体会宏的定义方法 阅读全文
posted @ 2020-05-27 09:31 profesor 阅读(1333) 评论(0) 推荐(0) 编辑
摘要:Python ONE-LINER LIST COMPREHENSION 阅读全文
posted @ 2020-05-27 08:41 profesor 阅读(200) 评论(0) 推荐(0) 编辑
摘要:JAVA public class Args { public static void main(String[] args) { // for (String arg : args) // System.out.println(arg); //或者下面的遍历方法 for (int i = 0; i 阅读全文
posted @ 2020-05-26 23:38 profesor 阅读(192) 评论(0) 推荐(0) 编辑
摘要:/* 典型的Switch-case程序题: 成绩等级划分: >= 90 A >= 80 B >= 70 C >= 60 D < 60 E */ import java.util.Scanner; public class SwitchInt { public static void main(Str 阅读全文
posted @ 2020-05-26 10:47 profesor 阅读(1123) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> int main() { char a[] = "The quick brown fox jumps over the lazy dog."; a[4] = '\0'; //a[] = "The \0uick brown fox jumps over the l 阅读全文
posted @ 2020-05-26 10:18 profesor 阅读(945) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> //找出一维数组中最大最小的数 int max(int *array, int len); //原型声明 int min(int *array, int len); //原型声明 int main() { int a[] = {1, 2, 4, 7, 10, 1 阅读全文
posted @ 2020-05-26 10:03 profesor 阅读(672) 评论(0) 推荐(0) 编辑
摘要:一维数组的创建方法 //第一种创建array的方法: String[] familyMembers = new String[4]; familyMembers[0] = "jerry"; familyMembers[1] = "elaine"; familyMembers[2] = "george 阅读全文
posted @ 2020-05-25 22:45 profesor 阅读(679) 评论(0) 推荐(0) 编辑
摘要:public class Arrays { public static void main(String[] args) //返回值设为String { for (String name : names()) System.out.println(name); } public static Str 阅读全文
posted @ 2020-05-25 22:40 profesor 阅读(175) 评论(0) 推荐(0) 编辑
摘要://一维随机数组 public class RandomArray { public static void main(String[] args) { int[] nums = new int[(int) (Math.random() * 10)]; System.out.println("len 阅读全文
posted @ 2020-05-25 22:08 profesor 阅读(793) 评论(0) 推荐(0) 编辑
摘要://我们知道: Java有Math.random()来随机选择[0,1)内的任意数 //随机取数 // import java.util.Random; public class Choice { public static void main(String[] args) { Random rdm 阅读全文
posted @ 2020-05-25 21:56 profesor 阅读(2704) 评论(0) 推荐(0) 编辑
摘要:Array of arrays: #include <stdio.h> #include <string.h> int main() { char tracks[][100] = { "will the protesters in American cities bring progress", " 阅读全文
posted @ 2020-05-25 16:27 profesor 阅读(183) 评论(0) 推荐(0) 编辑
摘要:#!/bin/bash for item in * do if [ -f $item ] then echo $item fi done for do done if then (elif...then...) (else) fi 阅读全文
posted @ 2020-05-24 22:53 profesor 阅读(96) 评论(0) 推荐(0) 编辑
摘要:import java.util.Scanner; public class Reader { public static void main(String[] args) { Scanner scan = new Scanner(System.in); //创建对象 System.out.prin 阅读全文
posted @ 2020-05-24 22:45 profesor 阅读(420) 评论(0) 推荐(0) 编辑
摘要:import static java.lang.System.out; public class hello { public static void main(String[] args) { boolean bool = false; while (false) //这里如果直接换成while 阅读全文
posted @ 2020-05-24 22:29 profesor 阅读(218) 评论(0) 推荐(0) 编辑
摘要:Tech's push to teach coding isn't about kids' success – it's about cutting wages Ben Tarnoff Today’s hi-tech wages threaten Silicon Valley’s bottom li 阅读全文
posted @ 2020-05-23 20:07 profesor 阅读(155) 评论(0) 推荐(0) 编辑
摘要:打开Potplayer后,按F5打开设置 Auto check for updates: 选中Never Auto download files if ... 不要勾选 完成后点击右下角的OK 如果还是不行,在修改位于C:\Windows\System32\drivers\etc下的hosts文件, 阅读全文
posted @ 2020-05-23 11:28 profesor 阅读(496) 评论(0) 推荐(0) 编辑
摘要:web_scraping_package.py from bs4 import BeautifulSoup import requests session = requests.Session() headers = { 'User-agent': 'Mozilla/5.0 (Windows NT 阅读全文
posted @ 2020-05-22 18:10 profesor 阅读(148) 评论(0) 推荐(0) 编辑
摘要:texlive-base – 160 MB texlive-latex-recommended – 203 MB texlive – 269 MB texlive-latex-extra – 464 MB texlive-full – 5903 MB reference: https://linux 阅读全文
posted @ 2020-05-21 17:25 profesor 阅读(841) 评论(0) 推荐(0) 编辑
摘要:public class Test { public static void main (String[] args) { String[] a = {"roll out", "rule out", "normalcy", "palaver", "satirical", "rut"}; //下面提供 阅读全文
posted @ 2020-05-20 17:34 profesor 阅读(283) 评论(0) 推荐(0) 编辑
摘要:import java.util.Scanner; //调用java.util.Scanner public class Test { public static void main (String[] args) { Scanner keyboardInput = new Scanner(Syst 阅读全文
posted @ 2020-05-20 17:18 profesor 阅读(1173) 评论(0) 推荐(0) 编辑
摘要:import java.io.IOException; public class Test { public static void main (String[] args) throws IOException { char a = (char) System.in.read(); //默认接受i 阅读全文
posted @ 2020-05-20 17:03 profesor 阅读(177) 评论(0) 推荐(0) 编辑
摘要:public class getchar { public static void main(String[] args) throws java.io.IOException //必不可少 { int num = System.in.read(); //读进来的数,默认保存为整数,如果需要输出 刚 阅读全文
posted @ 2020-05-18 09:30 profesor 阅读(927) 评论(0) 推荐(0) 编辑
摘要:list comprehension: my_list = [num*num for num in range(1,11)] print(my_list) if使用 my_list = [num for num in range(1,11) if num > 5] print(my_list) if 阅读全文
posted @ 2020-05-16 23:38 profesor 阅读(189) 评论(0) 推荐(0) 编辑
摘要:VirtualBox: How to share folders from Windows to Ubuntu https://www.youtube.com/watch?v=NkGmp4ETjRs 阅读全文
posted @ 2020-05-12 21:48 profesor 阅读(105) 评论(0) 推荐(0) 编辑
摘要:terminal中输入 vim ~/.bashrc 添加如下内容 #newlyadded export PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin" 打开新的terminal,输入 ifconfig 成功 如果不行,试试安装net-tools sudo a 阅读全文
posted @ 2020-05-12 19:01 profesor 阅读(492) 评论(0) 推荐(0) 编辑
摘要:来源:https://blog.csdn.net/p309654858/article/details/131778994 进入 /etc/apt/路径cd /etc/apt/将sources.list备份保存为sources.backup.list,以防止有需要的时候更换回来cp -a sourc 阅读全文
posted @ 2020-05-12 07:57 profesor 阅读(2211) 评论(0) 推荐(0) 编辑
摘要:1.备份源文件 cp /etc/apt/sources.list /etc/apt/sources.list_bk 2.手动修改源文件 vim /etc/apt/sources.list 3.选择其中一个源 #中科大 deb http://mirrors.ustc.edu.cn/kali kali- 阅读全文
posted @ 2020-05-12 07:55 profesor 阅读(815) 评论(0) 推荐(0) 编辑
摘要:创建hello.java文件, 输入: public class hello { public static void main(String[] args) { System.out.println("hello, world!"); } } 在hello.java所在的directory中, 打 阅读全文
posted @ 2020-05-09 22:37 profesor 阅读(2254) 评论(0) 推荐(0) 编辑
摘要:输出如下图形: * * * * * * * * * * * * * * * * * * * * * C语言代码 //打印倒三角图案 #include <stdio.h> void reversed_triangle(int n); //函数声明 int main() { int n; puts("需 阅读全文
posted @ 2020-05-08 16:54 profesor 阅读(1845) 评论(0) 推荐(1) 编辑
摘要:要求:输入一个正整数n, 再输入n个整数,将它们按从小到大的顺序输出 // 输入指定的整数,然后把整数按从小到大的顺序每5个一行输出 #include <stdio.h> void order(int *a, int len); //函数声明 int main() { int n; printf(" 阅读全文
posted @ 2020-05-07 23:19 profesor 阅读(415) 评论(0) 推荐(0) 编辑
摘要:int 变量的默认初始值为0 这可以写个小程序测试下: #include <stdio.h> int main() { int i; if (i == 0) { printf("Hola, mundo, i = %d\n", i); } return 0; } 运行结果为: Hola, mundo, 阅读全文
posted @ 2020-05-05 12:13 profesor 阅读(5784) 评论(0) 推荐(0) 编辑
摘要:random module三个常用function: randint, choice, shuffle import random print(random.randint(1,10)) #从1到10(两头都包含)中随机选择一个数 words = ['grable', 'craven', 'mave 阅读全文
posted @ 2020-05-04 20:59 profesor 阅读(208) 评论(0) 推荐(0) 编辑
摘要:输入一个正整数n(1<=n<=6),根据下式生成n阶方阵,将该方阵转置(行列互换)后输出。 a[i][j] = i*n+j+1 #include <stdio.h> int main() { int n; printf("输入方阵维数: \n"); scanf("%d", &n); int a[n] 阅读全文
posted @ 2020-05-04 17:36 profesor 阅读(238) 评论(0) 推荐(0) 编辑
摘要:要求: 输入2个正整数m和n(1<=m<=6, 1<=n<=6),然后输入矩阵a(m行n列)中的元素,分别求出各行元素之和,并输出。试编写相应程序 #include <stdio.h> int main() { int m, n; // m,n作为行、列数 scanf("%d", &m); scan 阅读全文
posted @ 2020-05-04 16:39 profesor 阅读(430) 评论(0) 推荐(0) 编辑
摘要:输入两数a,b,交换值后输出 #include <stdio.h> void swap(int *pa, int *pb) { int t; t = *pa; *pa = *pb; *pb = t; } int main() { int a, b; printf("input two numbers 阅读全文
posted @ 2020-05-04 08:59 profesor 阅读(149) 评论(0) 推荐(0) 编辑
摘要:refactoring: 把求平均数与输出大于平均数的数的代码,都写成了函数 程序的修改: #define MAX 10 只需要对这里的10进行修改,就可以计算所需要的数量的数的平均值 比如,修改如下: #define MAX 20 编译运行时,需要输入20个数,即可输出这20个数的平均数与大于平均 阅读全文
posted @ 2020-05-03 22:31 profesor 阅读(708) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> int main() { char a[] = {'C', 'H', 'i', 'n', 'a', '\0'}; //等价于 char a[] = "CHina"; printf("sizeof(a)=%ld\n", sizeof(a)); for (int i 阅读全文
posted @ 2020-05-03 21:47 profesor 阅读(108) 评论(0) 推荐(0) 编辑
摘要:pi = 3.14159265 print(f"{pi:.5f}") # 或者使用: print(f"{'%.5f'%pi}") # 保留小数点后5位,四舍五入 输出结果 3.14159 3.14159 阅读全文
posted @ 2020-05-03 09:49 profesor 阅读(189) 评论(0) 推荐(0) 编辑
摘要:问题:如何输出0001, 0002, 0003... 这样的数 for i in range(1,21): print(f"{i:04}") 这里的4是宽度(width),0作为padding,即宽度不足4时,用0补上 输出结果 0001 0002 0003 0004 0005 0006 0007 阅读全文
posted @ 2020-05-03 09:40 profesor 阅读(895) 评论(0) 推荐(0) 编辑
摘要:#!/usr/bin/python3 print("hello, world!") name = 'Jerry' print(f"Hello, {name}, welcome back.") sum = 0 for i in range(1, 101): sum += i print(f"sum = 阅读全文
posted @ 2020-05-02 18:42 profesor 阅读(135) 评论(0) 推荐(0) 编辑
摘要:C语言代码: #include <stdio.h> int main() { int i, j; i=j=1; for (i=1;i<10;i++) { for (j=1;j<=i;j++) { printf("%dx%d=%d", j, i, i*j); //注意j与i的顺序 if (i*j < 阅读全文
posted @ 2020-05-02 00:00 profesor 阅读(411) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示