Skip to content

Commit f7cda7b

Browse files
committed
Modify itertools.py and print.py and move new feature trial file to specific directory
Signed-off-by: Jackey <mjjackey@163.com>
1 parent 446dcf4 commit f7cda7b

File tree

5 files changed

+11
-7
lines changed

5 files changed

+11
-7
lines changed

Self.py renamed to PythonNewFeature/Self.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ def __init__(self, name: str):
77
def clone(self) -> Self: # 返回类型是当前类或其子类
88
return type(self)(self.name)
99

10-
class Dog(Animal):
1110
def bark(self) -> str:
1211
return "Woof!"
1312

File renamed without changes.
File renamed without changes.

itertools.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
from itertools import batched
33
numbers: list[int]=[1,2,3,4,5,6,7]
44
my_batch: batched=batched(numbers,n=3)
5-
print(list(my_batch))
5+
print(list(my_batch)) # [(1, 2, 3), (4, 5, 6), (7,)]
66
my_batch2: batched=batched(numbers,n=2)
7-
print(next(my_batch2))
8-
print(next(my_batch2))
7+
print(next(my_batch2)) # (1, 2)
8+
print(next(my_batch2)) #(3, 4)
99

1010
#2. zip_longest()
1111
from itertools import zip_longest

print.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
if __name__ == "__main__":
22
PI = 3.141592653
3-
print('%10.3f'%PI)
3+
print('PI=%10.3f'%PI) # 精度为3, 总长为10, 需要缩进.
44

5-
print("PI=%.*f" % (3, PI))
65
# 用*从后面的元组中读取字段宽度或精度,可以读取出来精度是3位
76
# PI=3.142
87
# 没有指定宽度,所以不需要缩进
9-
print("PI=%*.3f" % (10, PI)) # 精度为3,总长为10.
8+
print("PI=%.*f" % (3, PI))
9+
10+
print("PI=%*.3f" % (10, PI)) # 精度为3, 总长为10, 需要缩进.
11+
12+
str_temp='%.2f %s haha $%d'
13+
str1 = str_temp % (4.88,'hola',2)
14+
print(str1)
1015

0 commit comments

Comments
 (0)