feat: format codes
This commit is contained in:
@@ -8,6 +8,7 @@ class Person():
|
|||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return repr((self.name, self.age))
|
return repr((self.name, self.age))
|
||||||
|
|
||||||
|
|
||||||
people = [
|
people = [
|
||||||
Person("tom", 22),
|
Person("tom", 22),
|
||||||
Person("jack", 11),
|
Person("jack", 11),
|
||||||
|
|||||||
12
functions.py
12
functions.py
@@ -2,21 +2,25 @@
|
|||||||
|
|
||||||
do_add = lambda a, b: a + b
|
do_add = lambda a, b: a + b
|
||||||
|
|
||||||
|
|
||||||
def do_add_2(a, b):
|
def do_add_2(a, b):
|
||||||
return a + b
|
return a + b
|
||||||
|
|
||||||
def incr(base, inc = 1):
|
|
||||||
|
def incr(base, inc=1):
|
||||||
return base + inc
|
return base + inc
|
||||||
|
|
||||||
def var_args(first_arg = "first", *args):
|
|
||||||
|
def var_args(first_arg="first", *args):
|
||||||
print("fist arg:", first_arg)
|
print("fist arg:", first_arg)
|
||||||
print("rest args:", args)
|
print("rest args:", args)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print("1 + 2 =", do_add(1, 2))
|
print("1 + 2 =", do_add(1, 2))
|
||||||
print("1 + 2 =", do_add_2(1, 2))
|
print("1 + 2 =", do_add_2(1, 2))
|
||||||
print("1 inc 1 =", incr(1))
|
print("1 inc 1 =", incr(1))
|
||||||
print("1 inc 1 =", incr(1, inc = 1))
|
print("1 inc 1 =", incr(1, inc=1))
|
||||||
print("1 inc 2 =", incr(1, inc = 2))
|
print("1 inc 2 =", incr(1, inc=2))
|
||||||
var_args()
|
var_args()
|
||||||
var_args("fist argument", "1", "2", "3")
|
var_args("fist argument", "1", "2", "3")
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
def is_leap_year(year: int):
|
def is_leap_year(year: int):
|
||||||
return year % 4 == 0 and year % 100 != 0 or year % 400 == 0
|
return year % 4 == 0 and year % 100 != 0 or year % 400 == 0
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print(1582, is_leap_year(1582))
|
print(1582, is_leap_year(1582))
|
||||||
print(2000, is_leap_year(2000))
|
print(2000, is_leap_year(2000))
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import socket
|
import socket
|
||||||
import ssl
|
import ssl
|
||||||
|
|
||||||
|
|
||||||
def get_server_certificate(hostname, port=443):
|
def get_server_certificate(hostname, port=443):
|
||||||
# context = ssl.create_default_context()
|
# context = ssl.create_default_context()
|
||||||
context = ssl._create_unverified_context()
|
context = ssl._create_unverified_context()
|
||||||
@@ -11,6 +12,7 @@ def get_server_certificate(hostname, port=443):
|
|||||||
cert = ssock.getpeercert()
|
cert = ssock.getpeercert()
|
||||||
return cert
|
return cert
|
||||||
|
|
||||||
|
|
||||||
# not success, but why?
|
# not success, but why?
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
certificate = get_server_certificate("hatter.ink")
|
certificate = get_server_certificate("hatter.ink")
|
||||||
|
|||||||
Reference in New Issue
Block a user