1月 052021
 
File -> Settings -> Project -> Python Interpreter -> Install -> Available Packages -> Manage Repositories

https://mirrors.163.com/pypi/simple/
https://mirrors.ustc.edu.cn/pypi/web/simple
https://pypi.tuna.tsinghua.edu.cn/simple
https://mirrors.aliyun.com/pypi/simple/
12月 242020
 
https://ipinfo.io/developers
C:\Users\harveymei>curl ipinfo.io
{
"ip": "119.137.55.106",
"city": "Shenzhen",
"region": "Guangdong",
"country": "CN",
"loc": "22.5455,114.0683",
"org": "AS4134 CHINANET-BACKBONE",
"timezone": "Asia/Shanghai",
"readme": "https://ipinfo.io/missingauth"
}
C:\Users\harveymei>
10月 122020
 
#定义一个创建文件的函数
def create_file():
    path = 'C:/Users/harveymei/Desktop/' #最后一个斜线必须有
    fullname = path + filename + '.txt'
    file = open(fullname, 'w')
    file.close()

#使用for循环调用创建文件函数
for name in range(1,11): #使用range()函数提供1-10序列数值
    filename = str(name) #使用str()函数将整数转换为字符串赋值给变量
    create_file() #循环调用函数,创建10个文件
PS D:\Python> & C:/Users/harveymei/AppData/Local/Programs/Python/Python39/python.exe d:/Python/hello.py
PS D:\Python> ls C:\Users\harveymei\Desktop\


    目录: C:\Users\harveymei\Desktop


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        2020/10/12     11:51              0 1.txt
-a----        2020/10/12     11:51              0 10.txt
-a----        2020/10/12     11:51              0 2.txt
-a----        2020/10/12     11:51              0 3.txt
-a----        2020/10/12     11:51              0 4.txt
-a----        2020/10/12     11:51              0 5.txt
-a----        2020/10/12     11:51              0 6.txt
-a----        2020/10/12     11:51              0 7.txt
-a----        2020/10/12     11:51              0 8.txt
-a----        2020/10/12     11:51              0 9.txt
-a----         2020/10/9      9:00           2136 Docker Desktop.lnk
-a----         2020/4/14      8:55           2371 GitHub Desktop.lnk
-a----         2020/8/28     15:20           2312 Kindle.lnk
-a----         2020/8/21     17:59           2255 MockingBot.lnk
-a----        2020/10/10      9:40           2217 Slack.lnk


PS D:\Python>
10月 092020
 
#定义密码列表并赋值给变量
password_list = ['*#*#', '12345']
#定义函数
def account_login():
    password = input('Password:') #用户输入赋值变量
    password_correct = password == password_list[-1] #使用列表索引取值进行布尔运算并赋值变量
    password_reset = password == password_list[0]
    if password_correct: #条件成立打印信息
        print('Login success!')
    elif password_reset: #反之,password_reset条件成立(即输入*#*#)
        new_password = input('Enter a new password:') #用户输入赋值变量
        password_list.append(new_password) #列表追加数据
        print('Your password has changed successfully!')
        account_login() #继续调用函数
    else: #反之,打印错误信息
        print('Wrong password or invalid input!')
        account_login()
#调用函数
account_login()
PS C:\Users\harveymei> & C:/Users/harveymei/AppData/Local/Programs/Python/Python39/python.exe c:/Users/harveymei/hello.py
Password:54321
Wrong password or invalid input!
Password:12345
Login success!
PS C:\Users\harveymei> & C:/Users/harveymei/AppData/Local/Programs/Python/Python39/python.exe c:/Users/harveymei/hello.py
Password:*#*#
Enter a new password:hahaha
Your password has changed successfully!
Password:hahaha
Login success!
PS C:\Users\harveymei>
9月 232020
 
#自定义函数,a*a+b*b=c*c,开平方求c值
def Pythagorean_theorem(a,b):
    return 'The right triangle third side\'s length is {}'.format((a**2 + b**2)**(1/2))
#引号内的字符串出现符号时需要使用\转义
#使用.format()将格式化的运算值填入字符串中

#调用函数,传入参数并打印函数返回
print(Pythagorean_theorem(3,4))
PS C:\Users\harveymei> & C:/Users/harveymei/AppData/Local/Programs/Python/Python38/python.exe c:/Users/harveymei/hello.py
The right triangle third side's length is 5.0
PS C:\Users\harveymei> 
9月 232020
 
#6的2次方
print(6**2)
#6的4次方
print(6**4)
#36的2次方
print(36**2)
#开平方
#1296的1/2次方
print((6**4)**(1/2))
#1296的1/4次方
print((6**4)**(1/4))
PS C:\Users\harveymei> & C:/Users/harveymei/AppData/Local/Programs/Python/Python38/python.exe c:/Users/harveymei/hello.py
36
1296
1296
36.0
6.0
PS C:\Users\harveymei> 
9月 222020
 
#自定义函数,重量克转化为千克
def g2kg(g):
    kg = g / 1000
    return str(kg) + 'kg'

#调用函数并赋值变量
result = g2kg(2500)
#打印变量
print(result)
PS C:\Users\harveymei> & C:/Users/harveymei/AppData/Local/Programs/Python/Python38/python.exe c:/Users/harveymei/hello.py
2.5kg
PS C:\Users\harveymei>
7月 282020
 

CentOS 8

编译报错(提示为nghttp2版本太旧)

[root@test httpd-2.4.43]# ./configure --enable-http2

checking for nghttp2... checking for user-provided nghttp2 base directory... none
checking for pkg-config along ... checking for nghttp2 version >= 1.2.1... FAILED
configure: WARNING: nghttp2 version is too old

启用仅CentOS 8支持的Power Tools软件源仓库

可供 CentOS 使用的软件库
https://wiki.centos.org/zh/AdditionalResources/Repositories

PowerTools —— 只供 CentOS8 使用,PowerTools 软件库提供了大量开发者用的工具。缺省是停用的。

[root@test httpd-2.4.43]# dnf config-manager --set-enabled PowerTools
[root@test httpd-2.4.43]# dnf makecache
CentOS-8 - AppStream                                           9.6 kB/s | 4.3 kB     00:00
CentOS-8 - Base                                                8.6 kB/s | 3.9 kB     00:00
CentOS-8 - Extras                                              4.4 kB/s | 1.5 kB     00:00
CentOS-8 - PowerTools                                          1.7 MB/s | 1.9 MB     00:01
Extra Packages for Enterprise Linux Modular 8 - x86_64          57 kB/s |  18 kB     00:00
Extra Packages for Enterprise Linux 8 - x86_64                  58 kB/s |  18 kB     00:00
Metadata cache created.
[root@test httpd-2.4.43]#

安装开发库

[root@test httpd-2.4.43]# dnf -y install libnghttp2-devel

===============================================================================================
 Package                   Architecture    Version                   Repository           Size
===============================================================================================
Installing:
 libnghttp2-devel          x86_64          1.33.0-3.el8_2.1          PowerTools           60 k

Transaction Summary
===============================================================================================
Install  1 Package

重新编译

[root@test httpd-2.4.43]# ./configure --enable-http2

checking whether to enable mod_http2... checking dependencies
checking for OpenSSL... (cached) yes
  setting MOD_LDFLAGS to "-lssl -lcrypto    -lpthread -ldl"
  setting MOD_CFLAGS to ""
  setting MOD_CPPFLAGS to "-DH2_OPENSSL"
checking for nghttp2... checking for user-provided nghttp2 base directory... none
checking for pkg-config along ...   setting MOD_CFLAGS to ""
checking for nghttp2 version >= 1.2.1... OK
  adding "-lnghttp2" to MOD_LDFLAGS
  setting LIBS to "-lnghttp2    -lpthread -ldl"
checking nghttp2/nghttp2.h usability... yes
checking nghttp2/nghttp2.h presence... yes
checking for nghttp2/nghttp2.h... yes
checking for nghttp2_session_server_new2... yes
checking for nghttp2_stream_get_weight... yes
checking for nghttp2_session_change_stream_priority... yes
  adding "-DH2_NG2_CHANGE_PRIO" to MOD_CPPFLAGS
checking for nghttp2_session_callbacks_set_on_invalid_header_callback... yes
  adding "-DH2_NG2_INVALID_HEADER_CB" to MOD_CPPFLAGS
checking for nghttp2_session_get_stream_local_window_size... yes
  adding "-DH2_NG2_LOCAL_WIN_SIZE" to MOD_CPPFLAGS
yes
  setting MOD_HTTP2_LDADD to "-export-symbols-regex http2_module"
7月 012020
 

查看系统时间日期配置

[centos@dev ~]$ sudo timedatectl
[sudo] password for centos:
               Local time: Wed 2020-07-01 09:21:55 UTC
           Universal time: Wed 2020-07-01 09:21:55 UTC
                 RTC time: Wed 2020-07-01 09:21:55
                Time zone: UTC (UTC, +0000)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no
[centos@dev ~]$
[centos@dev ~]$ sudo timedatectl --help
timedatectl [OPTIONS...] COMMAND ...

Query or change system time and date settings.

  -h --help                Show this help message
     --version             Show package version
     --no-pager            Do not pipe output into a pager
     --no-ask-password     Do not prompt for password
  -H --host=[USER@]HOST    Operate on remote host
  -M --machine=CONTAINER   Operate on local container
     --adjust-system-clock Adjust system clock when changing local RTC mode
     --monitor             Monitor status of systemd-timesyncd
  -p --property=NAME       Show only properties by this name
  -a --all                 Show all properties, including empty ones
     --value               When showing properties, only print the value

Commands:
  status                   Show current time settings
  show                     Show properties of systemd-timedated
  set-time TIME            Set system time
  set-timezone ZONE        Set system time zone
  list-timezones           Show known time zones
  set-local-rtc BOOL       Control whether RTC is in local time
  set-ntp BOOL             Enable or disable network time synchronization

systemd-timesyncd Commands:
  timesync-status          Show status of systemd-timesyncd
  show-timesync            Show properties of systemd-timesyncd
[centos@dev ~]$

修改系统时区

[centos@dev ~]$ sudo timedatectl set-timezone Asia/Hong_Kong
[centos@dev ~]$ date
Wed Jul  1 17:22:59 HKT 2020
[centos@dev ~]$
[centos@dev ~]$ sudo timedatectl
               Local time: Wed 2020-07-01 17:24:20 HKT
           Universal time: Wed 2020-07-01 09:24:20 UTC
                 RTC time: Wed 2020-07-01 09:24:20
                Time zone: Asia/Hong_Kong (HKT, +0800)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no
[centos@dev ~]$